sktime.utils.validation.forecasting

sktime.utils.validation.forecasting.check_X(X, allow_empty=False, enforce_univariate=False, enforce_index_type=None)[source]

Validate input data.

Parameters
  • X (pd.Series, pd.DataFrame, np.ndarray) –

  • allow_empty (bool, optional (default=False)) – If False, empty X raises an error.

  • enforce_index_type (type, optional (default=None)) – type of time index

  • enforce_univariate (bool, optional (default=False)) – If True, multivariate X will raise an error.

Returns

X – Validated input data.

Return type

pd.Series, pd.DataFrame

Raises
sktime.utils.validation.forecasting.check_alpha(alpha)[source]

Check that a confidence level alpha (or list of alphas) is valid. All alpha values must lie in the open interval (0, 1). :param alpha: :type alpha: float, list of float

Raises

ValueError – If alpha is outside the range (0, 1).

sktime.utils.validation.forecasting.check_cutoffs(cutoffs)[source]

Validates the cutoff

Parameters

cutoffs (np.ndarray or pd.Index) –

Returns

Return type

cutoffs (Sorted array)

Raises

ValueError – If cutoffs is not a instance of np.array or pd.Index If cutoffs array is empty.

sktime.utils.validation.forecasting.check_cv(cv)[source]

Check CV generators.

Parameters

cv (CV generator) –

Raises

ValueError – if cv does not have the required attributes.

sktime.utils.validation.forecasting.check_fh(fh, enforce_relative=False)[source]

Validate forecasting horizon.

Parameters
  • fh (int, list, np.array, pd.Index or ForecastingHorizon) – Forecasting horizon specifying the time points to predict.

  • enforce_relative (bool, optional (default=False)) – If True, checks if fh is relative.

Returns

fh – Validated forecasting horizon.

Return type

ForecastingHorizon

sktime.utils.validation.forecasting.check_scoring(scoring)[source]

Validates the performace scoring

Parameters

scoring (object of class MetricFunctionWrapper from sktime.performance_metrics.) –

Returns

  • scoring (object of class MetricFunctionWrapper of sktime.performance_metrics.)

  • sMAPE(mean percentage error) – if the object is None.

Raises

TypeError – if object is not callable from current scope. if object is not an instance of class MetricFunctionWrapper of sktime.performance_metrics.

sktime.utils.validation.forecasting.check_sp(sp, enforce_list=False)[source]

Validate seasonal periodicity.

Parameters
  • sp (int or [int/float]) – Seasonal periodicity

  • emforce_list (bool, optional (default=False)) – If true, convert sp to list if not list.

Returns

sp – Validated seasonal periodicity

Return type

int or [int/float]

sktime.utils.validation.forecasting.check_step_length(step_length)[source]

Validate window length. :param step_length: :type step_length: step length for data set.

Returns

step_length – if step_length in not none and is int and greater than or equal to 1.

Return type

int

Raises

ValueError – if step_length is negative or not an integer or is None.

sktime.utils.validation.forecasting.check_y(y, allow_empty=False, allow_constant=True, enforce_index_type=None)[source]

Validate input data.

Parameters
  • y (pd.Series) –

  • allow_empty (bool, optional (default=False)) – If False, empty y raises an error.

  • allow_constant (bool, optional (default=True)) – If True, constant y does not raise an error.

  • enforce_index_type (type, optional (default=None)) – type of time index

Returns

y

Return type

pd.Series

Raises

ValueError, TypeError – If y is an invalid input

sktime.utils.validation.forecasting.check_y_X(y, X=None, allow_empty=False, allow_constant=True, enforce_index_type=None)[source]

Validate input data.

Parameters
  • y (pd.Series) –

  • X (pd.DataFrame, optional (default=None)) –

  • allow_empty (bool, optional (default=False)) – If True, empty y does not raise an error.

  • allow_constant (bool, optional (default=True)) – If True, constant y does not raise an error.

  • enforce_index_type (type, optional (default=None)) – type of time index

Raises

ValueError – If y or X are invalid inputs