sktime.forecasting.base¶
-
class
sktime.forecasting.base.
BaseForecaster
[source]¶ Bases:
sktime.base._base.BaseEstimator
Base forecaster
The base forecaster specifies the methods and method signatures that all forecasters have to implement.
Specific implementations of these methods is deferred to concrete forecasters.
-
compute_pred_int
(y_pred, alpha=0.05)[source]¶ Get the prediction intervals for a forecast.
If alpha is iterable, multiple intervals will be calculated.
- Parameters
- Returns
intervals – A table of upper and lower bounds for each point prediction in
y_pred
. Ifalpha
was iterable, thenintervals
will be a list of such tables.- Return type
pd.DataFrame
-
fit
(y, X=None, fh=None)[source]¶ Fit to training data.
- Parameters
- Returns
self
- Return type
returns an instance of self.
-
predict
(fh=None, X=None, return_pred_int=False, alpha=0.05)[source]¶ Make forecasts
- Parameters
- Returns
y_pred (pd.Series) – Point predictions
y_pred_int (pd.DataFrame) – Prediction intervals
-
score
(y, X=None, fh=None)[source]¶ Compute the sMAPE loss for the given forecasting horizon.
- Parameters
y (pd.Series) – Target time series to which to compare the forecasts.
fh (int, list or array-like, optional (default=None)) – The forecasters horizon with the steps ahead to to predict.
X (pd.DataFrame, shape=[n_obs, n_vars], optional (default=None)) – An optional 2-d dataframe of exogenous variables.
- Returns
score – sMAPE loss of self.predict(fh, X) with respect to y_test.
- Return type
-
update
(y, X=None, update_params=True)[source]¶ Update fitted parameters
- Parameters
y (pd.Series) –
X (pd.DataFrame) –
update_params (bool, optional (default=True)) –
- Returns
self
- Return type
an instance of self
-
-
class
sktime.forecasting.base.
ForecastingHorizon
(values=None, is_relative=True)[source]¶ Bases:
object
Forecasting horizon
- Parameters
-
is_all_in_sample
(cutoff=None)[source]¶ Whether or not the forecasting horizon is purely in-sample for given cutoff.
-
is_all_out_of_sample
(cutoff=None)[source]¶ Whether or not the forecasting horizon is purely out-of-sample for given cutoff.
-
property
is_relative
[source]¶ Whether forecasting horizon is relative to the end of the training series.
- Returns
is_relative
- Return type
-
to_absolute
(cutoff)[source]¶ Return absolute values :param cutoff: Cutoff value is required to convert a relative forecasting
horizon to an absolute one and vice versa.
- Returns
fh – Absolute representation of forecasting horizon
- Return type
-
to_absolute_int
(start, cutoff=None)[source]¶ Return absolute values as zero-based integer index starting from start.
- Parameters
- Returns
fh – Absolute representation of forecasting horizon as zero-based integer index
- Return type
-
to_in_sample
(cutoff=None)[source]¶ Return in-sample values
- Parameters
cutoff (pd.Period, pd.Timestamp, int, optional (default=None)) – Cutoff value is required to convert a relative forecasting horizon to an absolute one and vice versa.
- Returns
fh – In-sample values of forecasting horizon
- Return type
-
to_indexer
(cutoff=None, from_cutoff=True)[source]¶ Return zero-based indexer values for easy indexing into arrays.
- Parameters
cutoff (pd.Period, pd.Timestamp, int, optional (default=None)) – Cutoff value is required to convert a relative forecasting horizon to an absolute one and vice versa.
from_cutoff (bool, optional (default=True)) –
If True, zero-based relative to cutoff.
If False, zero-based relative to first value in forecasting
horizon.
- Returns
fh – Indexer
- Return type
pd.Index
-
to_numpy
(**kwargs)[source]¶ Returns underlying values as np.array
- Parameters
**kwargs (dict of kwargs) – kwargs passed to to_numpy() of wrapped pandas index.
- Returns
fh
- Return type
np.ndarray
-
to_out_of_sample
(cutoff=None)[source]¶ Return out-of-sample values :param cutoff: Cutoff value is required to convert a relative forecasting
horizon to an absolute one and vice versa.
- Returns
fh – Out-of-sample values of forecasting horizon
- Return type