Forecaster
CurveFitForecaster
The CurveFitForecaster takes a function and fits it by using scipy curve_fit.
Quickstart
python
from sktime.forecasting.trend import CurveFitForecaster
estimator = CurveFitForecaster(function, curve_fit_params=None, origin='unix_zero', normalise_index=False)Parameters(4)
- function: Callable[[Iterable[float], …], Iterable[float]]
The function that should be fitted and used to make forecasts. The signature of the functions is
function(x,...). It takes the independent variables as first argument and the parameters to fit as separate remaining arguments. See scipy.optimize.curve_fit for more information.- curve_fit_params: dict, default=None
- Additional parameters that should be passed to the curve_fit method. See scipy.optimize.curve_fit for more information.
- origin: {“unix_zero”, “first_index”}, default=”unix_zero”
- The origin of the time series index.
- normalise_index: bool, default=False
- If True, the differences between the index values are normalised by setting the difference between the first and second index value to one.
Examples
>>> from sktime.forecasting.trend import CurveFitForecaster
>>> from sktime.datasets import load_airline
>>> y = load_airline ()
>>> def linear_function (x, a, b):
... return a * x + b
>>> forecaster = CurveFitForecaster (function = linear_function,
... curve_fit_params = { "p0":[- 1, 1 ]})
>>> forecaster. fit (y) CurveFitForecaster(
... )
>>> y_pred = forecaster. predict (fh = [1, 2, 3 ])