ForecastingHorizon#

class ForecastingHorizon(values: Optional[Union[int, list, numpy.ndarray, pandas.core.indexes.base.Index]] = None, is_relative: Optional[bool] = None)[source]#

Forecasting horizon.

Parameters
valuespd.Index, pd.TimedeltaIndex, np.array, list, pd.Timedelta, or int

Values of forecasting horizon

is_relativebool, optional (default=None)
  • If True, a relative ForecastingHorizon is created:

    values are relative to end of training series.

  • If False, an absolute ForecastingHorizon is created:

    values are absolute.

  • if None, the flag is determined automatically:

    relative, if values are of supported relative index type absolute, if not relative and values of supported absolute index type

Attributes
is_relative

Whether forecasting horizon is relative to the end of the training series.

Methods

is_all_in_sample([cutoff])

Whether the forecasting horizon is purely in-sample for given cutoff.

is_all_out_of_sample([cutoff])

Whether the forecasting horizon is purely out-of-sample for given cutoff.

to_absolute(cutoff)

Return absolute version of forecasting horizon values.

to_absolute_int(start[, cutoff])

Return absolute values as zero-based integer index starting from start.

to_in_sample([cutoff])

Return in-sample index values of fh.

to_indexer([cutoff, from_cutoff])

Return zero-based indexer values for easy indexing into arrays.

to_numpy(**kwargs)

Return forecasting horizon’s underlying values as np.array.

to_out_of_sample([cutoff])

Return out-of-sample values of fh.

to_pandas()

Return forecasting horizon’s underlying values as pd.Index.

to_relative([cutoff])

Return forecasting horizon values relative to a cutoff.

property is_relative: bool[source]#

Whether forecasting horizon is relative to the end of the training series.

Returns
is_relativebool
to_pandas() pandas.core.indexes.base.Index[source]#

Return forecasting horizon’s underlying values as pd.Index.

Returns
fhpd.Index

pandas Index containing forecasting horizon’s underlying values.

to_numpy(**kwargs) numpy.ndarray[source]#

Return forecasting horizon’s underlying values as np.array.

Parameters
**kwargsdict of kwargs

kwargs passed to to_numpy() of wrapped pandas index.

Returns
fhnp.ndarray

NumPy array containg forecasting horizon’s underlying values.

to_relative(cutoff=None)[source]#

Return forecasting horizon values relative to a cutoff.

Parameters
cutoffpd.Period, pd.Timestamp, int, optional (default=None)

Cutoff value required to convert a relative forecasting horizon to an absolute one (and vice versa).

Returns
fhForecastingHorizon

Relative representation of forecasting horizon.

to_absolute(cutoff)[source]#

Return absolute version of forecasting horizon values.

Parameters
cutoffpd.Period, pd.Timestamp, int

Cutoff value is required to convert a relative forecasting horizon to an absolute one (and vice versa).

Returns
fhForecastingHorizon

Absolute representation of forecasting horizon.

to_absolute_int(start, cutoff=None)[source]#

Return absolute values as zero-based integer index starting from start.

Parameters
startpd.Period, pd.Timestamp, int

Start value returned as zero.

cutoffpd.Period, pd.Timestamp, int, optional (default=None)

Cutoff value required to convert a relative forecasting horizon to an absolute one (and vice versa).

Returns
fhForecastingHorizon

Absolute representation of forecasting horizon as zero-based integer index.

to_in_sample(cutoff=None)[source]#

Return in-sample index values of fh.

Parameters
cutoffpd.Period, pd.Timestamp, int, optional (default=None)

Cutoff value required to convert a relative forecasting horizon to an absolute one (and vice versa).

Returns
fhForecastingHorizon

In-sample values of forecasting horizon.

to_out_of_sample(cutoff=None)[source]#

Return out-of-sample values of fh.

Parameters
cutoffpd.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
fhForecastingHorizon

Out-of-sample values of forecasting horizon.

is_all_in_sample(cutoff=None) bool[source]#

Whether the forecasting horizon is purely in-sample for given cutoff.

Parameters
cutoffpd.Period, pd.Timestamp, int, default=None

Cutoff value used to check if forecasting horizon is purely in-sample.

Returns
retbool

True if the forecasting horizon is purely in-sample for given cutoff.

is_all_out_of_sample(cutoff=None) bool[source]#

Whether the forecasting horizon is purely out-of-sample for given cutoff.

Parameters
cutoffpd.Period, pd.Timestamp, int, optional (default=None)

Cutoff value used to check if forecasting horizon is purely out-of-sample.

Returns
retbool

True if the forecasting horizon is purely out-of-sample for given cutoff.

to_indexer(cutoff=None, from_cutoff=True)[source]#

Return zero-based indexer values for easy indexing into arrays.

Parameters
cutoffpd.Period, pd.Timestamp, int, optional (default=None)

Cutoff value required to convert a relative forecasting horizon to an absolute one and vice versa.

from_cutoffbool, optional (default=True)
  • If True, zero-based relative to cutoff.

  • If False, zero-based relative to first value in forecasting

horizon.

Returns
fhpd.Index

Indexer.