Plans
skforecast_ai.schemas.plans ¶
Classes:
| Name | Description |
|---|---|
CVParams |
LLM-produced cross-validation parameters for |
PreprocessingStep |
A preprocessing action required before forecasting. |
WindowFeature |
A single rolling-window feature specification for a forecaster. |
PlanOverrides |
LLM-produced overrides for a forecasting plan. |
ForecastPlan |
Detailed forecasting plan produced from a |
Attributes¶
Classes¶
CVParams ¶
Bases: BaseModel
LLM-produced cross-validation parameters for TimeSeriesFold.
Returned as structured output from the CV configuration agent. All fields have defaults so the LLM only needs to specify the parameters it wants to override from the deterministic baseline.
Attributes:
| Name | Type | Description |
|---|---|---|
initial_train_size |
(int, float, str)
|
Number of observations (int), fraction of data (float in (0, 1)), or date string for the initial training set. |
refit |
(bool, int)
|
Whether to refit every fold (True), never (False), or every n folds (int). |
fixed_train_size |
bool
|
If True, training size stays fixed; if False, expands. |
gap |
int
|
Observations between end of training and start of test. |
fold_stride |
(int, None)
|
Observations between consecutive test set starts. None means equal to steps. |
skip_folds |
int, list of int, None
|
Folds to skip. Int means keep every n-th fold; list specifies indexes. |
allow_incomplete_fold |
bool
|
Whether to allow a final fold with fewer observations than steps. |
reasoning |
str
|
Explanation of why these parameters were chosen. Shown to the user for transparency. |
Attributes¶
initial_train_size
class-attribute
instance-attribute
¶
initial_train_size = Field(
description="Number of observations (int), fraction of total data (float in (0,1)), or date string for the initial training set."
)
refit
class-attribute
instance-attribute
¶
refit = Field(
default=True,
description="Whether to refit the model every fold (True), never (False), or every n folds (int).",
)
fixed_train_size
class-attribute
instance-attribute
¶
fixed_train_size = Field(
default=False,
description="If True, training window stays fixed (rolling). If False, training window expands each fold.",
)
gap
class-attribute
instance-attribute
¶
gap = Field(
default=0,
description="Number of observations between training end and test start.",
)
fold_stride
class-attribute
instance-attribute
¶
fold_stride = Field(
default=None,
description="Number of observations between consecutive test set starts. None defaults to steps (non-overlapping test sets).",
)
skip_folds
class-attribute
instance-attribute
¶
skip_folds = Field(
default=None,
description="Folds to skip. Int keeps every n-th fold; list specifies fold indexes to skip.",
)
allow_incomplete_fold
class-attribute
instance-attribute
¶
allow_incomplete_fold = Field(
default=True,
description="Whether to allow a final fold with fewer observations than steps.",
)
reasoning
class-attribute
instance-attribute
¶
reasoning = Field(
description="Explanation of why these parameters were chosen, referencing the user's deployment scenario."
)
PreprocessingStep ¶
Bases: BaseModel
A preprocessing action required before forecasting.
Attributes:
| Name | Type | Description |
|---|---|---|
action |
str
|
Identifier for the preprocessing operation (e.g.
|
reason |
str
|
Human-readable explanation of why this step is needed. |
code_snippet |
str
|
Python code template that implements this step. May contain
format placeholders (e.g. |
blocking |
bool, default True
|
Whether skforecast will fail without this step. Non-blocking steps are recommended but optional. |
WindowFeature ¶
Bases: BaseModel
A single rolling-window feature specification for a forecaster.
Attributes:
| Name | Type | Description |
|---|---|---|
stats |
list of str
|
Rolling statistics to compute (e.g. |
window_size |
int
|
Rolling window length in observations, applied to every statistic
in |
Attributes¶
stats
class-attribute
instance-attribute
¶
stats = Field(
description="Rolling statistics to compute. Each value must be one of: 'mean', 'std', 'min', 'max', 'sum', 'median', 'ratio_min_max', 'coef_variation', 'ewm'."
)
window_size
class-attribute
instance-attribute
¶
window_size = Field(
description="Rolling window length in observations, e.g. 7. Scalar only: it is applied to every statistic in `stats`. Use one entry per window size to combine several sizes."
)
PlanOverrides ¶
Bases: BaseModel
LLM-produced overrides for a forecasting plan.
Attributes:
| Name | Type | Description |
|---|---|---|
lags |
list of int, int, default None
|
Overridden lag indices or lag count. |
window_features |
list of WindowFeature, default None
|
Overridden window features configurations. |
reasoning |
str
|
Explanation of why the LLM chose these features based on the user's domain knowledge prompt. |
Attributes¶
lags
class-attribute
instance-attribute
¶
lags = Field(
default=None,
description="The lag indices to use for the forecaster. E.g. [1, 2, 3, 7, 14] or an integer for consecutive lags.",
)
window_features
class-attribute
instance-attribute
¶
window_features = Field(
default=None,
description="The window features configurations to use. E.g. [{'stats': ['mean', 'std'], 'window_size': 7}].",
)
reasoning
class-attribute
instance-attribute
¶
reasoning = Field(
description="Explanation of why these specific features (lags and window features) were chosen based on the user's prompt and time series context."
)
ForecastPlan ¶
Bases: DisplayMixin, BaseModel
Detailed forecasting plan produced from a ForecastingProfile.
Carries every concrete decision needed to fit, evaluate and predict: lag structure, prediction intervals, NaN handling, exogenous usage and preprocessing steps.
Attributes:
| Name | Type | Description |
|---|---|---|
task_type |
str
|
Forecasting task category (mirrored from the source
|
forecaster |
str
|
Name of the skforecast forecaster class. |
forecaster_kwargs |
dict, default {}
|
Keyword arguments for the forecaster constructor (e.g. |
estimator |
str, default None
|
Name of the scikit-learn compatible estimator. |
estimator_kwargs |
dict, default {}
|
Keyword arguments for the estimator constructor (e.g.
|
steps |
int
|
Number of steps ahead to predict. Must be greater than 0. |
frequency |
str, default None
|
Pandas frequency string for the series. |
end_train |
str, default None
|
Last datetime (inclusive) of the training set as a string
(e.g. |
interval |
list, default None
|
Prediction interval quantiles as |
interval_method |
str, default None
|
Method for prediction intervals. One of |
metric |
str, default 'mean_absolute_error'
|
Recommended primary evaluation metric (string name matching sklearn/skforecast naming conventions). |
metrics_to_compute |
(list, default['mean_absolute_error', 'mean_squared_error', 'mean_absolute_scaled_error'])
|
Full list of metrics to evaluate in generated code. |
use_exog |
bool, default False
|
Whether to include exogenous variables. |
preprocessing_steps |
list
|
Ordered list of preprocessing steps required before forecasting. |
warnings |
list
|
Human-readable warnings about the plan. |
llm_refined_fields |
list
|
Names of the fields ( |
explanation |
str
|
Explanation of the plan-level decisions. |
Attributes¶
forecaster_kwargs
class-attribute
instance-attribute
¶
forecaster_kwargs = Field(default_factory=dict)
estimator_kwargs
class-attribute
instance-attribute
¶
estimator_kwargs = Field(default_factory=dict)
metrics_to_compute
class-attribute
instance-attribute
¶
metrics_to_compute = Field(
default_factory=lambda: [
"mean_absolute_error",
"mean_squared_error",
"mean_absolute_scaled_error",
]
)
preprocessing_steps
class-attribute
instance-attribute
¶
preprocessing_steps = Field(default_factory=list)
llm_refined_fields
class-attribute
instance-attribute
¶
llm_refined_fields = Field(default_factory=list)
Functions¶
_rich_body ¶
_rich_body(console, options)
Source code in skforecast_ai/schemas/plans.py
274 275 | |