ts_parameters_data_check#

检查时间序列参数是否与数据大小兼容的数据检查。

模块内容#

类摘要#

TimeSeriesParametersDataCheck

检查时间序列参数是否与数据分割兼容。

目录#

evalml.data_checks.ts_parameters_data_check.TimeSeriesParametersDataCheck(problem_configuration, n_splits)[源]#

检查时间序列参数是否与数据分割兼容。

如果 gap + max_delay + forecast_horizon > X.shape[0] // (n_splits + 1)

则特征工程窗口大于最小的分割。这将导致流水线从不存在的数据创建特征,从而导致错误。

参数
  • problem_configuration (dict) – 包含 problem_configuration 参数的字典。

  • n_splits (int) – 时间序列分割的数量。

方法

name

返回描述数据检查的名称。

validate

检查时间序列参数是否与数据分割兼容。

name(cls)#

返回描述数据检查的名称。

validate(self, X, y=None)[源]#

检查时间序列参数是否与数据分割兼容。

参数
  • X (pd.DataFrame, np.ndarray) – 特征。

  • y (pd.Series, np.ndarray) – 忽略。默认为 None。

返回值

如果参数对于分割大小来说太大,则返回一个包含 DataCheckError 的字典。

返回类型

dict

示例

>>> import pandas as pd

时间序列参数必须与传入的数据兼容。如果窗口大小 (gap + max_delay + forecast_horizon) 大于或等于分割大小,则会引发错误。

>>> X = pd.DataFrame({
...    "dates": pd.date_range("1/1/21", periods=100),
...    "first": [i for i in range(100)],
... })
>>> y = pd.Series([i for i in range(100)])
...
>>> problem_config = {"gap": 7, "max_delay": 2, "forecast_horizon": 12, "time_index": "dates"}
>>> ts_parameters_check = TimeSeriesParametersDataCheck(problem_configuration=problem_config, n_splits=7)
>>> assert ts_parameters_check.validate(X, y) == [
...     {
...         "message": "Since the data has 100 observations, n_splits=7, and a forecast horizon of 12, the smallest "
...                    "split would have 16 observations. Since 21 (gap + max_delay + forecast_horizon)"
...                    " >= 16, then at least one of the splits would be empty by the time it reaches "
...                    "the pipeline. Please use a smaller number of splits, reduce one or more these "
...                    "parameters, or collect more data.",
...         "data_check_name": "TimeSeriesParametersDataCheck",
...         "level": "error",
...         "code": "TIMESERIES_PARAMETERS_NOT_COMPATIBLE_WITH_SPLIT",
...         "details": {
...             "columns": None,
...             "rows": None,
...             "max_window_size": 21,
...             "min_split_size": 16,
...             "n_obs": 100,
...             "n_splits": 7
...         },
...         "action_options": []
...     }
... ]