Prophet#

class Prophet(freq=None, add_seasonality=None, add_country_holidays=None, growth='linear', growth_floor=0.0, growth_cap=None, changepoints=None, n_changepoints=25, changepoint_range=0.8, yearly_seasonality='auto', weekly_seasonality='auto', daily_seasonality='auto', holidays=None, seasonality_mode='additive', seasonality_prior_scale=10.0, holidays_prior_scale=10.0, changepoint_prior_scale=0.05, mcmc_samples=0, alpha=0.05, uncertainty_samples=1000, stan_backend=None, verbose=0, fit_kwargs=None)[source]#

Prophet 预测器,封装了 Facebook 的 prophet 算法 [1]

使用 sktime 接口直接调用 Facebook prophet。所有超参数通过构造函数暴露。

数据可以使用 sktime 兼容的格式之一传递,无需像 prophet 包中那样将某列命名为 ds

与原生 prophet 不同,也支持整数/范围和周期索引: * 整数/范围索引解释为自 2000 年 1 月 1 日以来的天数 * PeriodIndex 使用 pandas 方法 to_timestamp 进行转换

参数:
freq: str, default=None

一个 DatetimeIndex 频率。可能的值请参见 https://pandas.ac.cn/pandas-docs/stable/user_guide/timeseries.html

add_seasonality: dict or None, default=None

包含 Prophet.add_seasonality() 参数的字典。字典可以包含以下键/值:

  • name: 季节性分量的字符串名称。

  • period: 一个周期的天数(浮点数)。

  • fourier_order: 要使用的傅里叶分量数量(整数)。

  • prior_scale: 此分量的可选先验尺度(浮点数)。

  • mode: 可选的“加法”或“乘法”

  • condition_name: 季节性条件的字符串名称。

add_country_holidays: dict or None, default=None

包含 Prophet.add_country_holidays() 参数的字典。字典可以包含以下键/值:

country_name: 国家名称,例如“UnitedStates”或“US”

growth: str, default=”linear”

字符串“linear”或“logistic”用于指定线性或逻辑趋势。如果指定为“logistic”,则必须提供“growth_cap”的浮点数。

growth_floor: float, default=0

增长饱和最小值。仅当 growth="logistic" 时使用,否则无效(如果 growth 不是 "logistic")。

growth_cap: float, default=None

增长饱和最大值,也称为承载能力。仅当 growth="logistic" 时强制要求为浮点数,否则无效且为可选(如果 growth 不是 "logistic")。

changepoints: list or None, default=None

包含潜在变点的日期列表。如果未指定,则自动选择潜在变点。

n_changepoints: int, default=25

要包含的潜在变点数量。如果提供了输入 changepoints 则不使用。如果未提供 changepoints,则从历史记录的前 changepoint_range 比例中均匀选择 n_changepoints 个潜在变点。

changepoint_range: float, default=0.8

趋势变点将被估计的历史记录比例。默认为前 80% 的历史记录(即 0.8)。如果指定了 changepoints 则不使用。

yearly_seasonality: str or bool or int, default=”auto”

拟合年度季节性。可以是“auto”、True、False 或要生成的傅里叶项数量。

weekly_seasonality: str or bool or int, default=”auto”

拟合每周季节性。可以是“auto”、True、False 或要生成的傅里叶项数量。

daily_seasonality: str or bool or int, default=”auto”

拟合每日季节性。可以是“auto”、True、False 或要生成的傅里叶项数量。

holidays: pd.DataFrame or None, default=None

一个 pd.DataFrame,包含 holiday(字符串)和 ds(日期类型)列,以及可选的 lower_window 和 upper_window 列,用于指定日期前后包含为节假日的日期范围。lower_window=-2 将包含日期前 2 天作为节假日。还可以可选地包含一个 prior_scale 列,用于指定该节假日的先验尺度。

seasonality_mode: str, default=’additive’

取“additive”或“multiplicative”之一。

seasonality_prior_scale: float, default=10.0

调节季节性模型强度的参数。值越大,模型可以拟合更大的季节性波动,值越小则抑制季节性。可以使用 add_seasonality 为单独的季节性指定。

holidays_prior_scale: float, default=10.0

调节节假日分量模型强度的参数,除非在 holidays 输入中被覆盖。

changepoint_prior_scale: float, default=0.05

调节自动变点选择灵活性的参数。值越大,允许的变点越多;值越小,允许的变点越少。

mcmc_samples: int, default=0

如果大于 0,将使用指定数量的 MCMC 样本进行全贝叶斯推断。如果为 0,将进行 MAP 估计。

alpha: float, default=0.05

为预测提供的置信区间宽度。如果 mcmc_samples=0,这将仅是使用外推生成模型的 MAP 估计值计算的趋势不确定性。如果 mcmc.samples>0,这将对所有模型参数进行积分,其中将包含季节性的不确定性。

uncertainty_samples: int, default=1000

用于估计置信区间的模拟抽样数量。将此值设置为 0 或 False 将禁用不确定性估计并加快计算速度。

stan_backend: str or None, default=None

StanBackendEnum 中定义的字符串。如果为 None,将尝试迭代所有可用的后端并找到可用的。

fit_kwargs: dict or None, default=None

包含 Prophet.fit() 参数的字典。这些是传递给 Stan 中优化或抽样函数的附加参数。

属性:
cutoff

截止点 = 预测器的“当前时间”状态。

fh

传递的预测范围。

is_fitted

fit 是否已被调用。

参考资料

示例

>>> from sktime.datasets import load_airline
>>> from sktime.forecasting.fbprophet import Prophet
>>> # Prophet requires to have data with a pandas.DatetimeIndex
>>> y = load_airline().to_timestamp(freq='M')
>>> forecaster = Prophet(  
...     seasonality_mode='multiplicative',
...     n_changepoints=int(len(y) / 12),
...     add_country_holidays={'country_name': 'Germany'},
...     yearly_seasonality=True)
>>> forecaster.fit(y)  
Prophet(...)
>>> y_pred = forecaster.predict(fh=[1,2,3])  

方法

check_is_fitted([method_name])

检查评估器是否已拟合。

clone()

获取一个具有相同超参数和配置的对象的克隆。

clone_tags(estimator[, tag_names])

从另一个对象克隆标签作为动态覆盖。

create_test_instance([parameter_set])

使用第一个测试参数集构建类的实例。

create_test_instances_and_names([parameter_set])

创建所有测试实例及其名称列表。

fit(y[, X, fh])

将预测器拟合到训练数据。

fit_predict(y[, X, fh, X_pred])

拟合并在未来范围内预测时间序列。

get_class_tag(tag_name[, tag_value_default])

从类中获取类标签值,包含来自父类的标签级别继承。

get_class_tags()

从类中获取类标签,包含来自父类的标签级别继承。

get_config()

获取自身的配置标志。

get_fitted_params([deep])

获取已拟合的参数。

get_param_defaults()

获取对象的参数默认值。

get_param_names([sort])

获取对象的参数名称。

get_params([deep])

获取此对象的参数值字典。

get_tag(tag_name[, tag_value_default, ...])

从实例中获取标签值,包含标签级别继承和覆盖。

get_tags()

从实例中获取标签,包含标签级别继承和覆盖。

get_test_params([parameter_set])

返回评估器的测试参数设置。

is_composite()

检查对象是否由其他 BaseObjects 组成。

load_from_path(serial)

从文件位置加载对象。

load_from_serial(serial)

从序列化的内存容器加载对象。

predict([fh, X])

在未来范围内预测时间序列。

predict_interval([fh, X, coverage])

计算/返回预测区间预测。

predict_proba([fh, X, marginal])

计算/返回完全概率预测。

predict_quantiles([fh, X, alpha])

计算/返回分位数预测。

predict_residuals([y, X])

返回时间序列预测的残差。

predict_var([fh, X, cov])

计算/返回方差预测。

reset()

将对象重置到初始化后的干净状态。

save([path, serialization_format])

将序列化的自身保存到字节类对象或 (.zip) 文件。

score(y[, X, fh])

使用 MAPE(非对称)对预测结果进行评分,与真实值进行比较。

set_config(**config_dict)

将配置标志设置为给定值。

set_params(**params)

设置此对象的参数。

set_random_state([random_state, deep, ...])

为自身设置 random_state 伪随机种子参数。

set_tags(**tag_dict)

将实例级别的标签覆盖设置为给定值。

update(y[, X, update_params])

更新截止点值,并可选地更新已拟合参数。

update_predict(y[, cv, X, update_params, ...])

在测试集上迭代地进行预测和更新模型。

update_predict_single([y, fh, X, update_params])

用新数据更新模型并进行预测。

classmethod get_test_params(parameter_set='default')[source]#

返回评估器的测试参数设置。

参数:
parameter_setstr, default=”default”

要返回的测试参数集的名称,用于测试。如果没有为某个值定义特殊参数,将返回 "default" 集。

返回:
paramsdict or list of dict
params: 字典或字典列表

检查评估器是否已拟合。

check_is_fitted(method_name=None)[source]#

检查 _is_fitted 属性是否存在且为 True。在调用对象的 fit 方法时,is_fitted 属性应设置为 True

参数:
如果不是,则引发 NotFittedError

method_namestr, optional

调用此函数的方法的名称。如果提供,错误消息将包含此信息。
NotFittedError

抛出:

如果评估器尚未拟合。

获取一个具有相同超参数和配置的对象的克隆。

clone()[source]#

克隆是一个不同的对象,没有共享引用,处于初始化后状态。此函数等同于返回 selfsklearn.clone

等同于构造一个 type(self) 的新实例,并使用 self 的参数,即 type(self)(**self.get_params(deep=False))

如果在 self 上设置了配置,克隆也将具有与原始对象相同的配置,等同于调用 cloned_self.set_config(**self.get_config())

调用此函数的方法的名称。如果提供,错误消息将包含此信息。
在值上也等同于调用 self.reset,但不同的是 clone 返回一个新对象,而不是像 reset 那样改变 self
如果由于 __init__ 错误导致克隆不符合规范,则引发 RuntimeError。

从另一个对象克隆标签作为动态覆盖。

clone_tags(estimator, tag_names=None)[source]#

每个 scikit-base 兼容对象都有一个标签字典。标签可用于存储对象的元数据,或控制对象的行为。

clone_tags 从另一个对象 estimator 设置动态标签覆盖。

clone_tags 方法只能在对象的 __init__ 方法中,在构造过程中,或通过 __init__ 直接调用后调用。

动态标签被设置为 estimator 中标签的值,名称由 tag_names 指定。

tag_names 的默认设置是将 estimator 中的所有标签写入 self

当前标签值可以通过 get_tagsget_tag 进行检查。

参数:
estimatorAn instance of :class:BaseObject or derived class
estimator: :class:BaseObject 或派生类的实例

tag_namesstr or list of str, default = None

返回:
要克隆的标签名称。默认值(None)克隆 estimator 中的所有标签。

self

self 的引用。

使用第一个测试参数集构建类的实例。

参数:
parameter_setstr, default=”default”

classmethod create_test_instance(parameter_set='default')[source]#

返回:
要返回的测试参数集的名称,用于测试。如果没有为某个值定义特殊参数,将返回“default”集。
instanceinstance of the class with default parameters

创建所有测试实例及其名称列表。

参数:
parameter_setstr, default=”default”

classmethod create_test_instance(parameter_set='default')[source]#

返回:
instance: 具有默认参数的类实例

classmethod create_test_instances_and_names(parameter_set='default')[source]#

objslist of instances of cls

objs: cls 实例列表

i-th instance is cls(**cls.get_test_params()[i])

截止点 = 预测器的“当前时间”状态。

返回:
第 i 个实例是 cls(**cls.get_test_params()[i])

nameslist of str, same length as objs

names: 字符串列表,长度与 objs 相同

传递的预测范围。

i-th element is name of i-th instance of obj in tests. The naming convention is {cls.__name__}-{i} if more than one instance, otherwise {cls.__name__}

将预测器拟合到训练数据。

第 i 个元素是测试中第 i 个 obj 实例的名称。命名约定是 {cls.__name__}-{i}(如果实例多于一个)或 {cls.__name__}(否则)。

property cutoff[source]#

cutoffpandas compatible index element, or None

  • pandas 兼容的索引元素,或 None

  • pandas compatible index element, if cutoff has been set; None otherwise

  • pandas 兼容的索引元素,如果已设置截止点;否则为 None

  • property fh[source]#

参数:
传递的预测范围。

fit(y, X=None, fh=None)[source]#

状态改变

  • 将状态更改为“已拟合”。

  • 写入自身

  • 设置以“_”结尾的已拟合模型属性,已拟合属性可通过 get_fitted_params 检查。

self.is_fitted 标志设置为 True

self.cutoff 设置为在 y 中看到的最后一个索引。

如果传递了 fh,将其存储到 self.fh

ytime series in sktime compatible data container format.

y: sktime 兼容数据容器格式的时间序列。

返回:
Time series to which to fit the forecaster.
用于拟合预测器的时间序列。

拟合并在未来范围内预测时间序列。

Individual data formats in sktime are so-called mtype specifications, each mtype implements an abstract scitype.

第 i 个元素是测试中第 i 个 obj 实例的名称。命名约定是 {cls.__name__}-{i}(如果实例多于一个)或 {cls.__name__}(否则)。

property cutoff[source]#

cutoffpandas compatible index element, or None

  • pandas 兼容的索引元素,或 None

  • pandas compatible index element, if cutoff has been set; None otherwise

  • pandas 兼容的索引元素,如果已设置截止点;否则为 None

  • sktime 中的各种数据格式是所谓的 mtype 规范,每个 mtype 实现一个抽象的 scitype

参数:
Series scitype = individual time series, vanilla forecasting. pd.DataFrame, pd.Series, or np.ndarray (1D or 2D)

fit(y, X=None, fh=None)[source]#

状态改变

  • 将状态更改为“已拟合”。

  • 写入自身

  • 设置以“_”结尾的已拟合模型属性,已拟合属性可通过 get_fitted_params 检查。

self.is_fitted 标志设置为 True

Series scitype = 单个时间序列,普通预测。pd.DataFramepd.Seriesnp.ndarray(1D 或 2D)

Panel scitype = collection of time series, global/panel forecasting. pd.DataFrame with 2-level row MultiIndex (instance, time), 3D np.ndarray (instance, variable, time), list of Series typed pd.DataFrame

Panel scitype = 时间序列集合,全局/面板预测。具有 2 级行 MultiIndex (instance, time)pd.DataFrame3D np.ndarray (instance, variable, time)Series 类型 pd.DataFramelist

ytime series in sktime compatible data container format.

y: sktime 兼容数据容器格式的时间序列。

Hierarchical scitype = hierarchical collection, for hierarchical forecasting. pd.DataFrame with 3 or more level row MultiIndex (hierarchy_1, ..., hierarchy_n, time)

Hierarchical scitype = 分层集合,用于分层预测。具有 3 级或更多行 MultiIndex (hierarchy_1, ..., hierarchy_n, time)pd.DataFrame

返回:
For further details on data format, see glossary on mtype. For usage, see forecasting tutorial examples/01_forecasting.ipynb

有关数据格式的更多详细信息,请参阅 mtype 词汇表。有关用法,请参阅预测教程 examples/01_forecasting.ipynb

fhint, list, pd.Index coercible, or ForecastingHorizon, default=None

从类中获取类标签值,包含来自父类的标签级别继承。

fh: 整数、列表、可强制转换为 pd.Index 或 ForecastingHorizon,默认为 None

The forecasting horizon encoding the time stamps to forecast at. If self.get_tag("requires-fh-in-fit") is True, must be passed in fit, not optional

编码要预测的时间戳的预测范围。如果 self.get_tag("requires-fh-in-fit")True,则必须在 fit 中传递,不是可选的。

  1. Xtime series in sktime compatible format, optional (default=None).

  2. X: sktime 兼容格式的时间序列,可选(默认为 None)。

Exogeneous time series to fit the model to. Should be of same scitype (Series, Panel, or Hierarchical) as y. If self.get_tag("X-y-must-have-same-index"), X.index must contain y.index.

用于拟合模型的外生时间序列。应与 y 具有相同的 scitypeSeriesPanelHierarchical)。如果 self.get_tag("X-y-must-have-same-index")True,则 X.index 必须包含 y.index

selfReference to self.

参数:
self: 对自身的引用。

fit_predict(y, X=None, fh=None, X_pred=None)[source]#

fit(y, X, fh).predict(X_pred) 相同。如果未传递 X_pred,则与 fit(y, fh, X).predict(X) 相同。

fh 存储到 self.fh

返回:
ytime series in sktime compatible data container format

y: sktime 兼容数据容器格式的时间序列

fhint, list, pd.Index coercible, or ForecastingHorizon (not optional)

从类中获取类标签,包含来自父类的标签级别继承。

clone_tags(estimator, tag_names=None)[source]#

每个 scikit-base 兼容对象都有一个标签字典。标签可用于存储对象的元数据,或控制对象的行为。

fh: 整数、列表、可强制转换为 pd.Index 或 ForecastingHorizon(非可选)

The forecasting horizon encoding the time stamps to forecast at.

编码要预测的时间戳的预测范围。

  1. Xtime series in sktime compatible format, optional (default=None).

  2. X: sktime 兼容格式的时间序列,可选(默认为 None)。

Exogeneous time series to fit the model to. Should be of same scitype (Series, Panel, or Hierarchical) as y. If self.get_tag("X-y-must-have-same-index"), X.index must contain y.index.

If fh is not None and not of type ForecastingHorizon it is coerced to ForecastingHorizon via a call to _check_fh. In particular, if fh is of type pd.Index it is coerced via ForecastingHorizon(fh, is_relative=False)

如果 fh 不是 None 且不是 ForecastingHorizon 类型,则通过调用 _check_fh 将其强制转换为 ForecastingHorizon。特别是,如果 fh 是 pd.Index 类型,则通过 ForecastingHorizon(fh, is_relative=False) 将其强制转换。

用于拟合模型的外生时间序列。应与 y 具有相同的 scitypeSeriesPanelHierarchical)。如果 self.get_tag("X-y-must-have-same-index")True,则 X.index 必须包含 y.index

X_predtime series in sktime compatible format, optional (default=None)

X_pred: sktime 兼容格式的时间序列,可选(默认为 None)

Exogeneous time series to use in prediction. If passed, will be used in predict instead of X. Should be of same scitype (Series, Panel, or Hierarchical) as y in fit. If self.get_tag("X-y-must-have-same-index"), X.index must contain fh index reference.

在预测中使用的外生时间序列。如果传递,将在预测中代替 X 使用。应与 `fit` 中的 `y` 具有相同的 scitype(`Series`、`Panel` 或 `Hierarchical`)。如果 `self.get_tag("X-y-must-have-same-index")` 为 `True`,则 `X.index` 必须包含 `fh` 索引引用。

获取自身的配置标志。

y_predtime series in sktime compatible data container format

y_pred: sktime 兼容数据容器格式的时间序列

Point forecasts at fh, with same index as fh. y_pred has same type as the y that has been passed most recently: Series, Panel, Hierarchical scitype, same format (see above)

fh 的点预测,与 fh 具有相同的索引。y_pred 与最近传递的 y 具有相同的类型:SeriesPanelHierarchical scitype,相同的格式(见上文)。

返回:
classmethod get_class_tag(tag_name, tag_value_default=None)[source]#

Every scikit-base compatible object has a dictionary of tags, which are used to store metadata about the object.

每个 scikit-base 兼容对象都有一个标签字典,用于存储对象的元数据。

获取已拟合的参数。

The get_class_tag method is a class method, and retrieves the value of a tag taking into account only class-level tag values and overrides.

get_class_tag 方法是一个类方法,它仅考虑类级别的标签值和覆盖来检索标签的值。

参数:
It returns the value of the tag with name tag_name from the object, taking into account tag overrides, in the following order of descending priority

它返回对象中名为 tag_name 的标签的值,按以下优先级降序考虑标签覆盖:

  • Tags set in the _tags attribute of the class.

  • 在类的 _tags 属性中设置的标签。

返回:
Tags set in the _tags attribute of parent classes,

在父类的 _tags 属性中设置的标签,

  • in order of inheritance.

  • 按继承顺序。

  • Does not take into account dynamic tag overrides on instances, set via set_tags or clone_tags, that are defined on instances.

不考虑通过 set_tagsclone_tags 在实例上设置的动态标签覆盖。

To retrieve tag values with potential instance overrides, use the get_tag method instead.

返回:
要检索可能包含实例覆盖的标签值,请改用 get_tag 方法。

tag_namestr

tag_name: 字符串

Name of tag value.

参数:
标签值的名称。

tag_value_defaultany type

返回:
tag_value_default: 任意类型

Default/fallback value if tag is not found.

如果找不到标签,则使用默认/备用值。

获取此对象的参数值字典。

参数:
It returns the value of the tag with name tag_name from the object, taking into account tag overrides, in the following order of descending priority

tag_value

  • tag_value

  • Value of the tag_name tag in self. If not found, returns tag_value_default.

返回:
selftag_name 标签的值。如果找不到,则返回 tag_value_default

classmethod get_class_tags()[source]#

  • The get_class_tags method is a class method, and retrieves the value of a tag taking into account only class-level tag values and overrides.

  • 按继承顺序。

  • Does not take into account dynamic tag overrides on instances, set via set_tags or clone_tags, that are defined on instances.

get_class_tags 方法是一个类方法,它仅考虑类级别的标签值和覆盖来检索标签的值。

从实例中获取标签值,包含标签级别继承和覆盖。

clone_tags(estimator, tag_names=None)[source]#

每个 scikit-base 兼容对象都有一个标签字典。标签可用于存储对象的元数据,或控制对象的行为。

It returns a dictionary with keys being keys of any attribute of _tags set in the class or any of its parent classes.

  1. 它返回一个字典,键是类或其任何父类中设置的任何 _tags 属性的键。

Values are the corresponding tag values, with overrides in the following order of descending priority

  1. Xtime series in sktime compatible format, optional (default=None).

  2. X: sktime 兼容格式的时间序列,可选(默认为 None)。

Exogeneous time series to fit the model to. Should be of same scitype (Series, Panel, or Hierarchical) as y. If self.get_tag("X-y-must-have-same-index"), X.index must contain y.index.

参数:
self: 对自身的引用。

值是相应的标签值,覆盖按以下优先级降序排列:

Instances can override these tags depending on hyper-parameters.

实例可以根据超参数覆盖这些标签。

For including overrides from dynamic tags, use get_tags.

要包含动态标签的覆盖,请使用 get_tags

返回:
tag_value任意

selftag_name 标签的值。如果未找到,如果 raise_error 为 True 则引发错误,否则返回 tag_value_default

调用此函数的方法的名称。如果提供,错误消息将包含此信息。
ValueError,如果 raise_errorTrue

如果 tag_name 不在 self.get_tags().keys() 中,则会引发 ValueError

get_tags()[源代码]#

从实例中获取标签,包含标签级别继承和覆盖。

clone_tags(estimator, tag_names=None)[source]#

每个 scikit-base 兼容对象都有一个标签字典。标签可用于存储对象的元数据,或控制对象的行为。

get_tags 方法返回一个标签字典,其键可以是类或其任何父类中设置的任何 _tags 属性的键,或者通过 set_tagsclone_tags 设置的标签。

编码要预测的时间戳的预测范围。

  1. 它返回一个字典,键是类或其任何父类中设置的任何 _tags 属性的键。

Values are the corresponding tag values, with overrides in the following order of descending priority

  1. Xtime series in sktime compatible format, optional (default=None).

  2. X: sktime 兼容格式的时间序列,可选(默认为 None)。

Exogeneous time series to fit the model to. Should be of same scitype (Series, Panel, or Hierarchical) as y. If self.get_tag("X-y-must-have-same-index"), X.index must contain y.index.

返回:
collected_tagsdict(字典)

标签名称 : 标签值 对的字典。从通过嵌套继承收集的 _tags 类属性以及来自 _tags_dynamic 对象属性的任何覆盖和新标签中收集。

is_composite()[源代码]#

检查对象是否由其他 BaseObjects 组成。

复合对象是包含其他对象作为参数的对象。在实例上调用,因为这可能因实例而异。

返回:
composite: bool(布尔值)

一个对象是否包含任何参数,其值为 BaseObject 后代实例。

property is_fitted[源代码]#

fit 是否已被调用。

检查对象的 _is_fitted` 属性,该属性在对象构建期间应初始化为 ``False,并在调用对象的 fit 方法时设置为 True。

返回:
bool(布尔值)

估计器是否已 fit

classmethod load_from_path(serial)[源代码]#

从文件位置加载对象。

参数:
serialZipFile(path).open(“object) 的结果
返回:
解序列化 self,得到 cls.save(path)path 的输出
classmethod load_from_serial(serial)[源代码]#

从序列化的内存容器加载对象。

参数:
serialcls.save(None) 输出的第一个元素
返回:
解序列化 self,得到 cls.save(None) 的输出 serial
predict(fh=None, X=None)[源代码]#

在未来范围内预测时间序列。

The get_class_tag method is a class method, and retrieves the value of a tag taking into account only class-level tag values and overrides.

要求状态为“fitted”,即 self.is_fitted=True

访问 self 中的

  • 以“_”结尾的已拟合模型属性。

  • self.cutoff, self.is_fitted

cutoffpandas compatible index element, or None

如果传递了 fh 且之前未传递,则将 fh 存储到 self.fh

参数:
self.cutoff 设置为在 y 中看到的最后一个索引。

预测时间戳的预测范围。如果在 fit 中已传递,则不应再次传递。如果在 fit 中未传递,则必须传递,不是可选的。

Panel scitype = 时间序列集合,全局/面板预测。具有 2 级行 MultiIndex (instance, time)pd.DataFrame3D np.ndarray (instance, variable, time)Series 类型 pd.DataFramelist

Xsktime 兼容格式的时间序列,可选 (默认值=None)

预测中使用的外生时间序列。应与 fit 中的 y 具有相同的科学类型(SeriesPanelHierarchical)。如果 self.get_tag("X-y-must-have-same-index"),则 X.index 必须包含 fh 索引引用。

返回:
For further details on data format, see glossary on mtype. For usage, see forecasting tutorial examples/01_forecasting.ipynb

有关数据格式的更多详细信息,请参阅 mtype 词汇表。有关用法,请参阅预测教程 examples/01_forecasting.ipynb

predict_interval(fh=None, X=None, coverage=0.9)[源代码]#

计算/返回预测区间预测。

如果 coverage 是可迭代的,则将计算多个区间。

The get_class_tag method is a class method, and retrieves the value of a tag taking into account only class-level tag values and overrides.

要求状态为“fitted”,即 self.is_fitted=True

访问 self 中的

  • 以“_”结尾的已拟合模型属性。

  • self.cutoff, self.is_fitted

cutoffpandas compatible index element, or None

如果传递了 fh 且之前未传递,则将 fh 存储到 self.fh

参数:
self.cutoff 设置为在 y 中看到的最后一个索引。

预测时间戳的预测范围。如果在 fit 中已传递,则不应再次传递。如果在 fit 中未传递,则必须传递,不是可选的。

如果 fh 不为 None 且类型不为 ForecastingHorizon,则其在内部被强制转换为 ForecastingHorizon (通过 _check_fh)。

  • 如果 fhint 或类数组的 int,则被解释为相对预测范围,并被强制转换为相对 ForecastingHorizon(fh, is_relative=True)

  • 如果 fh 类型为 pd.Index,则被解释为绝对预测范围,并被强制转换为绝对 ForecastingHorizon(fh, is_relative=False)

Xsktime 兼容格式的时间序列,可选 (默认值=None)

预测中使用的外生时间序列。应与 fit 中的 y 具有相同的科学类型(SeriesPanelHierarchical)。如果 self.get_tag("X-y-must-have-same-index"),则 X.index 必须包含 fh 索引引用。

coveragefloat 或包含唯一值的 float 列表,可选 (默认值=0.90)

预测区间(s) 的名义覆盖率(s)

返回:
pred_intpd.DataFrame
列具有多级索引:第一级是 fity 的变量名,
第二级是计算区间的覆盖率分数。

顺序与输入的 coverage 相同。

第三级是字符串“lower”或“upper”,表示区间的下限/上限。

行索引是 fh,如果 fit 中使用的 y 是 Panel 或 Hierarchical,则附加(上层)级别等于实例级别。

条目是区间下限/上限的预测值,

对于列索引中的变量,在第二级列索引中的名义覆盖率下,根据第三级列索引是下限或上限,针对行索引。上限/下限区间预测相当于对 coverage 中的 c 计算 alpha = 0.5 - c/2, 0.5 + c/2 的分位数预测。

对于行索引对应的数据,列索引对应的变量,其值是在第二个列索引指定的名义覆盖度下,根据第三个列索引确定的区间下界或上界。 区间上界/下界预测值等同于在分位数水平 alpha = 0.5 - c/2 和 0.5 + c/2 时的分位数预测值,其中 c 是覆盖度。

predict_proba(fh=None, X=None, marginal=True)[源代码]#

计算/返回完全概率预测。

注意

  • 目前仅为 Series(非 Panel,非 Hierarchical)y 实现。

  • 返回的分布对象需要安装 skpro

The get_class_tag method is a class method, and retrieves the value of a tag taking into account only class-level tag values and overrides.

要求状态为“fitted”,即 self.is_fitted=True

访问 self 中的

  • 以“_”结尾的已拟合模型属性。

  • self.cutoff, self.is_fitted

cutoffpandas compatible index element, or None

如果传递了 fh 且之前未传递,则将 fh 存储到 self.fh

参数:
self.cutoff 设置为在 y 中看到的最后一个索引。

预测时间戳的预测范围。如果在 fit 中已传递,则不应再次传递。如果在 fit 中未传递,则必须传递,不是可选的。

如果 fh 不为 None 且类型不为 ForecastingHorizon,则其在内部被强制转换为 ForecastingHorizon (通过 _check_fh)。

  • 如果 fhint 或类数组的 int,则被解释为相对预测范围,并被强制转换为相对 ForecastingHorizon(fh, is_relative=True)

  • 如果 fh 类型为 pd.Index,则被解释为绝对预测范围,并被强制转换为绝对 ForecastingHorizon(fh, is_relative=False)

Xsktime 兼容格式的时间序列,可选 (默认值=None)

预测中使用的外生时间序列。应与 fit 中的 y 具有相同的科学类型(SeriesPanelHierarchical)。如果 self.get_tag("X-y-must-have-same-index"),则 X.index 必须包含 fh 索引引用。

marginalbool(布尔值),可选 (默认值=True)

返回的分布是否按时间索引是边缘分布

返回:
pred_distskpro BaseDistribution

如果 marginal=True 则是预测分布,如果 marginal=False 且方法已实现,则将是按时间点的边缘分布,否则将是联合分布

predict_quantiles(fh=None, X=None, alpha=None)[源代码]#

计算/返回分位数预测。

如果 alpha 是可迭代的,则将计算多个分位数。

The get_class_tag method is a class method, and retrieves the value of a tag taking into account only class-level tag values and overrides.

要求状态为“fitted”,即 self.is_fitted=True

访问 self 中的

  • 以“_”结尾的已拟合模型属性。

  • self.cutoff, self.is_fitted

cutoffpandas compatible index element, or None

如果传递了 fh 且之前未传递,则将 fh 存储到 self.fh

参数:
self.cutoff 设置为在 y 中看到的最后一个索引。

预测时间戳的预测范围。如果在 fit 中已传递,则不应再次传递。如果在 fit 中未传递,则必须传递,不是可选的。

如果 fh 不为 None 且类型不为 ForecastingHorizon,则其在内部被强制转换为 ForecastingHorizon (通过 _check_fh)。

  • 如果 fhint 或类数组的 int,则被解释为相对预测范围,并被强制转换为相对 ForecastingHorizon(fh, is_relative=True)

  • 如果 fh 类型为 pd.Index,则被解释为绝对预测范围,并被强制转换为绝对 ForecastingHorizon(fh, is_relative=False)

Xsktime 兼容格式的时间序列,可选 (默认值=None)

预测中使用的外生时间序列。应与 fit 中的 y 具有相同的科学类型(SeriesPanelHierarchical)。如果 self.get_tag("X-y-must-have-same-index"),则 X.index 必须包含 fh 索引引用。

alphafloat 或包含唯一值的 float 列表,可选 (默认值=[0.05, 0.95])

计算分位数预测时的概率或概率列表。

返回:
quantilespd.DataFrame
列具有多级索引:第一级是 fity 的变量名,

第二级是传递给函数的 alpha 值。

行索引是 fh,如果 fit 中使用的 y 是 Panel 或 Hierarchical,则附加(上层)级别等于实例级别。

条目是区间下限/上限的预测值,

条目是分位数预测值,对于列索引中的变量,

在第二级列索引中的分位数概率下,针对行索引。

predict_residuals(y=None, X=None)[源代码]#

返回时间序列预测的残差。

将计算在 y.index 处的预测值的残差。

如果在 fit 中必须传递 fh,则必须与 y.index 一致。如果 y 是 np.ndarray,并且在 fit 中没有传递 fh,则残差将在 fh 为 range(len(y.shape[0])) 时计算。

The get_class_tag method is a class method, and retrieves the value of a tag taking into account only class-level tag values and overrides.

要求状态为“fitted”。如果已设置 fh,则必须对应于 y 的索引(pandas 或整数)。

访问 self 中的

以“_”结尾的已拟合模型属性。self.cutoff, self._is_fitted

cutoffpandas compatible index element, or None

无。

参数:
Series scitype = individual time series, vanilla forecasting. pd.DataFrame, pd.Series, or np.ndarray (1D or 2D)

用于计算残差的真实观测时间序列。必须具有与 predict 的预期返回值相同的类型、维度和索引。

如果为 None,则使用目前为止见到的 y (self._y),特别是

  • 如果在单个 fit 调用之前,则生成样本内残差

  • 如果 fit 需要 fh,则它必须指向 fit 中 y 的索引

Xsktime 兼容格式的时间序列,可选 (默认值=None)

用于更新和预测的外生时间序列 应与 fity 具有相同的科学类型SeriesPanelHierarchical)。如果 self.get_tag("X-y-must-have-same-index"),则 X.index 必须包含 fh 索引引用和 y.index

返回:
y_ressktime 兼容数据容器格式的时间序列

fh 处的预测残差,索引与 fh 相同。y_res 的类型与最近传递的 y 相同:SeriesPanelHierarchical 科学类型,格式相同(见上文)。

predict_var(fh=None, X=None, cov=False)[源代码]#

计算/返回方差预测。

The get_class_tag method is a class method, and retrieves the value of a tag taking into account only class-level tag values and overrides.

要求状态为“fitted”,即 self.is_fitted=True

访问 self 中的

  • 以“_”结尾的已拟合模型属性。

  • self.cutoff, self.is_fitted

cutoffpandas compatible index element, or None

如果传递了 fh 且之前未传递,则将 fh 存储到 self.fh

参数:
self.cutoff 设置为在 y 中看到的最后一个索引。

预测时间戳的预测范围。如果在 fit 中已传递,则不应再次传递。如果在 fit 中未传递,则必须传递,不是可选的。

如果 fh 不为 None 且类型不为 ForecastingHorizon,则其在内部被强制转换为 ForecastingHorizon (通过 _check_fh)。

  • 如果 fhint 或类数组的 int,则被解释为相对预测范围,并被强制转换为相对 ForecastingHorizon(fh, is_relative=True)

  • 如果 fh 类型为 pd.Index,则被解释为绝对预测范围,并被强制转换为绝对 ForecastingHorizon(fh, is_relative=False)

Xsktime 兼容格式的时间序列,可选 (默认值=None)

预测中使用的外生时间序列。应与 fit 中的 y 具有相同的科学类型(SeriesPanelHierarchical)。如果 self.get_tag("X-y-must-have-same-index"),则 X.index 必须包含 fh 索引引用。

covbool(布尔值),可选 (默认值=False)

如果为 True,计算协方差矩阵预测。如果为 False,计算边缘方差预测。

返回:
pred_varpd.DataFrame,格式取决于 cov 变量
如果 cov=False
列名与 fit/update 中传递的 y 完全相同。

对于无名格式,列索引将是 RangeIndex。

行索引是 fh,附加级别等于实例级别,

条目是区间下限/上限的预测值,

从 fit 中看到的 y 得来。条目是方差预测值,针对列索引中的变量。给定变量和 fh 索引的方差预测是该变量和索引的预测方差,给定观测数据。

该变量和该索引对应的方差,基于观测数据。

如果 cov=True
列索引是多级索引:第一级是变量名(如上)

第二级是 fh。

行索引是 fh,附加级别等于实例级别,

条目是区间下限/上限的预测值,

条目是(协)方差预测值,针对列索引中的变量,以及

行和列中时间索引之间的协方差。

注意:不返回不同变量之间的协方差预测。

reset()[源代码]#

将对象重置到初始化后的干净状态。

结果是将 self 设置为调用构造函数后的直接状态,使用相同的超参数。通过 set_config 设置的配置值也保留。

reset 调用删除任何对象属性,除了

  • 超参数 = __init__ 的参数写入 self,例如,self.paramname,其中 paramname__init__ 的参数

  • 包含双下划线字符串“__”的对象属性。例如,名为“__myattr”的属性被保留。

  • 配置属性,配置保持不变。get_configreset 前后的结果相等。

类和对象方法,以及类属性也不受影响。

等同于 clone,区别在于 reset 修改 self 而非返回新对象。

在调用 self.reset() 后,self 在值和状态上与调用构造函数 ``type(self)(**self.get_params(deep=False))`` 后获得的对象相等。

返回:
要克隆的标签名称。默认值(None)克隆 estimator 中的所有标签。

重置到初始化后干净状态但保留当前超参数值的类实例。

save(path=None, serialization_format='pickle')[源代码]#

将序列化的自身保存到字节类对象或 (.zip) 文件。

行为:如果 path 为 None,返回内存中的序列化 self;如果 path 是文件位置,则将 self 存储在该位置作为 zip 文件。

保存的文件是 zip 文件,包含以下内容:_metadata - 包含 self 的类,即 type(self);_obj - 序列化的 self。此类使用默认序列化(pickle)。

参数:
pathNone 或文件位置 (str 或 Path)

如果为 None,则将 self 保存到内存对象;如果是文件位置,则将 self 保存到该文件位置。如果

  • path="estimator",则在当前工作目录(cwd)创建 zip 文件 estimator.zip

  • path="/home/stored/estimator",则 zip 文件 estimator.zip

存储在 /home/stored/ 中。

serialization_format: str(字符串),默认值 = “pickle”

用于序列化的模块。可用选项有“pickle”和“cloudpickle”。注意,非默认格式可能需要安装其他软依赖项。

返回:
如果 path 为 None - 内存中的序列化 self
如果 path 是文件位置 - 引用该文件的 ZipFile
score(y, X=None, fh=None)[源代码]#

使用 MAPE(非对称)对预测结果进行评分,与真实值进行比较。

参数:
ypd.Series, pd.DataFrame, or np.ndarray (1D or 2D)

要评分的时间序列

self.cutoff 设置为在 y 中看到的最后一个索引。

Panel scitype = collection of time series, global/panel forecasting. pd.DataFrame with 2-level row MultiIndex (instance, time), 3D np.ndarray (instance, variable, time), list of Series typed pd.DataFrame

Xpd.DataFrame 或 2D np.array,可选 (默认值=None)

要评分的外生时间序列 如果 self.get_tag(“X-y-must-have-same-index”) 为 True,则 X.index 必须包含 y.index

返回:
scorefloat(浮点数)

self.predict(fh, X) 相对于 y_test 的 MAPE 损失。

set_config(**config_dict)[源代码]#

将配置标志设置为给定值。

参数:
classmethod get_class_tag(tag_name, tag_value_default=None)[source]#

配置名称 : 配置值 对的字典。有效的配置、值及其含义如下所示

displaystr(字符串),“diagram” (默认值),或 “text”

jupyter 内核如何显示 self 的实例

  • “diagram” = html 框图表示

  • “text” = 字符串打印输出

print_changed_onlybool(布尔值),默认值=True

打印 self 时是否仅列出自默认值不同的参数 (True),或列出所有参数名称和值 (False)。不嵌套,即仅影响 self,不影响组件估计器。

warningsstr(字符串),“on” (默认值),或 “off”

是否引发警告,仅影响来自 sktime 的警告

  • “on” = 将引发来自 sktime 的警告

  • “off” = 将不引发来自 sktime 的警告

backend:parallelstr(字符串),可选,默认值=”None”

广播/向量化时用于并行处理的后端,以下之一:

  • “None”:顺序执行循环,简单的列表推导

  • “loky”、“multiprocessing”和“threading”:使用 joblib.Parallel

  • “joblib”:自定义和第三方 joblib 后端,例如 spark

  • “dask”:使用 dask,需要在环境中安装 dask

  • “ray”:使用 ray,需要在环境中安装 ray

backend:parallel:paramsdict(字典),可选,默认值={} (未传递参数)

作为配置传递给并行化后端的附加参数。有效键取决于 backend:parallel 的值

  • “None”:无附加参数,忽略 backend_params

  • “loky”、“multiprocessing”和“threading”:默认 joblib 后端,可以在此处传递 joblib.Parallel 的任何有效键,例如 n_jobs,但 backend 除外,它由 backend 直接控制。如果未传递 n_jobs,则默认为 -1,其他参数默认为 joblib 默认值。

  • “joblib”:自定义和第三方 joblib 后端,例如 spark。可以在此处传递 joblib.Parallel 的任何有效键,例如 n_jobsbackend 必须作为 backend_params 的一个键传递。如果未传递 n_jobs,则默认为 -1,其他参数默认为 joblib 默认值。

  • “dask”:可以传递 dask.compute 的任何有效键,例如 scheduler

  • “ray”:可以传递以下键

    • “ray_remote_args”:ray.init 有效键的字典

    • “shutdown_ray”:bool(布尔值),默认值=True;False 防止 ray

      在并行化后关闭。

    • “logger_name”:str(字符串),默认值=”ray”;要使用的 logger 名称。

    • “mute_warnings”:bool(布尔值),默认值=False;如果为 True,则抑制警告

remember_databool(布尔值),默认值=True

是否在 fit 中存储 self._X 和 self._y,并在 update 中更新。如果为 True,则存储并更新 self._X 和 self._y。如果为 False,则不存储和更新 self._X 和 self._y。这在使用 save 时减小了序列化大小,但 update 将默认为“不执行任何操作”,而非“使用所有见过的数据重新拟合”。

返回:
self对 self 的引用。

注意

更改对象状态,将 config_dict 中的配置复制到 self._config_dynamic。

set_params(**params)[源代码]#

设置此对象的参数。

该方法对简单的 skbase 对象和复合对象都有效。参数键字符串 <component>__<parameter> 可用于复合对象(即包含其他对象的对象),以访问组件 <component> 中的 <parameter>。字符串 <parameter> 不带 <component>__ 也可用于引用,如果引用是明确的(例如,没有两个组件参数具有相同的名称 <parameter>)。

参数:
**paramsdict(字典)

BaseObject 参数,键必须是 <component>__<parameter> 字符串。__ 后缀可以作为完整字符串的别名,如果在 get_params 键中唯一。

返回:
self对 self 的引用 (参数设置后)
set_random_state(random_state=None, deep=True, self_policy='copy')[源代码]#

为自身设置 random_state 伪随机种子参数。

通过 self.get_params 查找名为 random_state 的参数,并通过 set_params 将它们设置为由 random_state 通过 sample_dependent_seed 派生的整数。这些整数通过链式哈希进行采样,并保证种子随机生成器的伪随机独立性。

根据 self_policy 适用于 self 中的 random_state 参数,并且当且仅当 deep=True 时适用于其余组件对象。

注意:即使 self 没有 random_state 参数,或者没有任何组件具有 random_state 参数,也会调用 set_params。因此,set_random_state 将重置任何 scikit-base 对象,即使是没有 random_state 参数的对象。

参数:
random_stateint, RandomState instance 或 None, 默认值=None

伪随机数生成器,用于控制随机整数的生成。传递 int 可确保多次函数调用产生可重现的输出。

It returns the value of the tag with name tag_name from the object, taking into account tag overrides, in the following order of descending priority

是否在具有 skbase 对象值的参数(即组件估计器)中设置随机状态。

  • 如果为 False,则仅设置 selfrandom_state 参数(如果存在)。

  • 如果为 True,则也会设置组件对象中的 random_state 参数。

self_policystr(字符串),{“copy”, “keep”, “new”} 之一,默认值=”copy”
  • “copy”:self.random_state 设置为输入的 random_state

  • “keep”:self.random_state 保持不变

  • “new”:self.random_state 设置为新的随机状态,

派生自输入的 random_state,通常与其不同

返回:
self对 self 的引用
set_tags(**tag_dict)[源代码]#

将实例级别的标签覆盖设置为给定值。

fh: 整数、列表、可强制转换为 pd.Index 或 ForecastingHorizon,默认为 None

标签是特定于实例 self 的键值对,它们是对象构造后不更改的静态标志。它们可用于元数据检查或控制对象的行为。

set_tags 将动态标签覆盖设置为 tag_dict 中指定的值,其中键是标签名称,字典值是要设置的标签值。

set_tags 方法应仅在对象的 __init__ 方法中(构造期间)或通过 __init__ 构造后直接调用。

当前标签值可以通过 get_tagsget_tag 进行检查。

参数:
**tag_dictdict(字典)

标签名称 : 标签值 对的字典。

返回:
Self

对 self 的引用。

update(y, X=None, update_params=True)[源代码]#

更新截止点值,并可选地更新已拟合参数。

如果没有实现估计器特定的更新方法,则默认回退如下:

  • update_params=True:对所有至今为止观测到的数据进行拟合

  • update_params=False:仅更新 cutoff 并记住数据

The get_class_tag method is a class method, and retrieves the value of a tag taking into account only class-level tag values and overrides.

要求状态为“fitted”,即 self.is_fitted=True

访问 self 中的

  • 以“_”结尾的已拟合模型属性。

  • self.cutoff, self.is_fitted

cutoffpandas compatible index element, or None

  • self.cutoff 更新为 y 中见到的最新索引。

  • 如果 update_params=True,则更新以“_”结尾的已拟合模型属性。

参数:
传递的预测范围。

用于更新预测器的时间序列。

状态改变

  • 将状态更改为“已拟合”。

  • 写入自身

  • 设置以“_”结尾的已拟合模型属性,已拟合属性可通过 get_fitted_params 检查。

self.is_fitted 标志设置为 True

ytime series in sktime compatible data container format.

用于更新模型拟合的外生时间序列。应与 y 具有相同的 科学类型SeriesPanelHierarchical)。如果 self.get_tag("X-y-must-have-same-index"),则 X.index 必须包含 y.index

update_paramsbool(布尔值),可选 (默认值=True)

是否更新模型参数。如果为 False,则仅更新 cutoff,模型参数(例如系数)不更新。

返回:
self对 self 的引用
update_predict(y, cv=None, X=None, update_params=True, reset_forecaster=True)[源代码]#

在测试集上迭代地进行预测和更新模型。

进行多次 update / predict 执行链的简写,基于时间分割器 cv 进行数据回放。

与以下操作相同(如果只有 y, cv 是非默认值)

  1. self.update(y=cv.split_series(y)[0][0])

  2. 记住 self.predict() (稍后一次返回)

  3. self.update(y=cv.split_series(y)[1][0])

  4. 记住 self.predict() (稍后一次返回)

  5. 等等

  6. 返回所有记住的预测

如果没有实现估计器特定的更新方法,则默认回退如下:

  • update_params=True:对所有至今为止观测到的数据进行拟合

  • update_params=False:仅更新 cutoff 并记住数据

The get_class_tag method is a class method, and retrieves the value of a tag taking into account only class-level tag values and overrides.

要求状态为“fitted”,即 self.is_fitted=True

访问 self 中的

  • 以“_”结尾的已拟合模型属性。

  • self.cutoff, self.is_fitted

写入 self(除非 reset_forecaster=True
  • self.cutoff 更新为 y 中见到的最新索引。

  • 如果 update_params=True,则更新以“_”结尾的已拟合模型属性。

如果 reset_forecaster=True,不更新状态。

参数:
传递的预测范围。

用于更新预测器的时间序列。

状态改变

  • 将状态更改为“已拟合”。

  • 写入自身

  • 设置以“_”结尾的已拟合模型属性,已拟合属性可通过 get_fitted_params 检查。

self.is_fitted 标志设置为 True

cv继承自 BaseSplitter 的时间交叉验证生成器,可选

例如,SlidingWindowSplitterExpandingWindowSplitter;默认值 = ExpandingWindowSplitter,initial_window=1 和默认值 = y/X 中的单个数据点逐个添加并预测,initial_window = 1, step_length = 1, fh = 1

Xsktime 兼容格式的时间序列,可选 (默认值=None)

用于更新和预测的外生时间序列 应与 fity 具有相同的科学类型(SeriesPanelHierarchical)。如果 self.get_tag("X-y-must-have-same-index"),则 X.index 必须包含 fh 索引引用。

update_paramsbool(布尔值),可选 (默认值=True)

是否更新模型参数。如果为 False,则仅更新 cutoff,模型参数(例如系数)不更新。

reset_forecasterbool(布尔值),可选 (默认值=True)
  • 如果为 True,则不会更改预测器的状态,即使用副本运行更新/预测序列,并且 self 的 cutoff、模型参数、数据内存不会改变。

  • 如果为 False,则在运行更新/预测序列时会更新 self,就像直接调用更新/预测一样。

返回:
y_pred汇总来自多个分割批次的点预测的对象

格式取决于预测的总对(cutoff,绝对预测范围)

  • 如果绝对预测范围点的集合是唯一的:类型是 sktime 兼容数据容器格式的时间序列,输出中省略 cutoff,类型与最近传递的 y 相同:Series,Panel,Hierarchical 科学类型,格式相同(见上)。

  • 如果绝对预测范围点的集合不唯一:类型是 pandas DataFrame,行和列索引是时间戳,行索引对应于预测的 cutoff,列索引对应于预测的绝对预测范围,条目是根据行索引预测的列索引的点预测值,如果在该(cutoff,预测范围)对处未进行预测,则条目为 nan。

update_predict_single(y=None, fh=None, X=None, update_params=True)[源代码]#

用新数据更新模型并进行预测。

此方法适用于一步完成更新和预测。

如果没有实现估计器特定的更新方法,则默认回退是先更新,然后预测。

The get_class_tag method is a class method, and retrieves the value of a tag taking into account only class-level tag values and overrides.

get_class_tag 方法是一个类方法,它仅考虑类级别的标签值和覆盖来检索标签的值。

访问 self 中的

以“_”结尾的已拟合模型属性。指向已见过数据的指针,self._y 和 self.X。self.cutoff, self._is_fitted。如果 update_params=True,则更新以“_”结尾的模型属性。

cutoffpandas compatible index element, or None

通过附加行更新 self._y 和 self._X 以及 yX。将 self.cutoff 和 self._cutoff 更新为 y 中见到的最后一个索引。如果 update_params=True,

更新以“_”结尾的已拟合模型属性。

参数:
传递的预测范围。

用于更新预测器的时间序列。

状态改变

  • 将状态更改为“已拟合”。

  • 写入自身

  • 设置以“_”结尾的已拟合模型属性,已拟合属性可通过 get_fitted_params 检查。

self.is_fitted 标志设置为 True

self.cutoff 设置为在 y 中看到的最后一个索引。

预测时间戳的预测范围。如果在 fit 中已传递,则不应再次传递。如果在 fit 中未传递,则必须传递,不是可选的。

Xsktime 兼容格式的时间序列,可选 (默认值=None)

用于更新和预测的外生时间序列 应与 fity 具有相同的科学类型(SeriesPanelHierarchical)。如果 self.get_tag("X-y-must-have-same-index"),则 X.index 必须包含 fh 索引引用。

update_paramsbool(布尔值),可选 (默认值=True)

是否更新模型参数。如果为 False,则仅更新 cutoff,模型参数(例如系数)不更新。

返回:
For further details on data format, see glossary on mtype. For usage, see forecasting tutorial examples/01_forecasting.ipynb

有关数据格式的更多详细信息,请参阅 mtype 词汇表。有关用法,请参阅预测教程 examples/01_forecasting.ipynb