Skip to content

Results

skforecast_ai.schemas.results

Classes:

Name Description
RenderedScript

Structured representation of a rendered forecasting script.

CodeGenerationResult

Result of the forecast_code workflow.

ForecastResult

Result of the forecast workflow (executes the pipeline end-to-end).

BacktestResult

Result of the backtest workflow.

AskResult

Result of the ask workflow (requires LLM).

Classes

RenderedScript

Bases: BaseModel

Structured representation of a rendered forecasting script.

Splits the rendered script into logical sections so that forecast() can exec the core logic while forecast_code() returns the full standalone script.

Attributes:

Name Type Description
imports str

Import statements required by the script.

data_loading str

Code that loads data from CSV and sets up the index.

core str

Core execution logic (preprocessing, split, fit, predict, metrics). Operates on a pre-existing data DataFrame variable.

Attributes
imports instance-attribute
imports
data_loading instance-attribute
data_loading
core instance-attribute
core
full_script property
full_script

Return the complete standalone script (imports + loading + core).

executable property
executable

Return code suitable for exec() (imports + core, no CSV loading).

CodeGenerationResult

Bases: DisplayMixin, BaseModel

Result of the forecast_code workflow.

Attributes:

Name Type Description
profile ForecastingProfile

Profile of the input dataset and high-level modeling decisions.

plan ForecastPlan

Detailed forecasting plan.

code str

Generated Python script.

Attributes
profile instance-attribute
profile
plan instance-attribute
plan
code instance-attribute
code
Functions
_rich_body
_rich_body(console, options)
Source code in skforecast_ai/schemas/results.py
79
80
81
82
83
def _rich_body(
    self, console: Console, options: ConsoleOptions
) -> RenderResult:
    yield render_profile(self.profile)
    yield render_plan(self.plan)

ForecastResult

Bases: DisplayMixin, BaseModel

Result of the forecast workflow (executes the pipeline end-to-end).

Attributes:

Name Type Description
profile ForecastingProfile

Profile of the input dataset and high-level modeling decisions.

plan ForecastPlan

Detailed forecasting plan that was executed.

code str

Generated Python script equivalent to the execution.

metrics pandas DataFrame, None

Evaluation metrics. DataFrame with columns ['series', 'MAE', 'MSE', 'MASE']. For single-series tasks this contains one row; for multi-series tasks one row per level. None in prediction mode (test_size=None), where there is no ground truth to evaluate against.

predictions pandas DataFrame

Forecasted values for the requested steps. When prediction intervals (or quantiles) are requested, the corresponding bound columns are included alongside the point predictions.

Attributes
model_config class-attribute instance-attribute
model_config = ConfigDict(arbitrary_types_allowed=True)
profile instance-attribute
profile
plan instance-attribute
plan
code instance-attribute
code
metrics instance-attribute
metrics
predictions instance-attribute
predictions
Functions
_rich_body
_rich_body(console, options)
Source code in skforecast_ai/schemas/results.py
118
119
120
121
122
123
124
125
def _rich_body(
    self, console: Console, options: ConsoleOptions
) -> RenderResult:
    yield render_profile(self.profile)
    yield render_plan(self.plan)
    if self.metrics is not None:
        yield render_metrics(self.metrics, title="Forecast Metrics")
    yield render_dataframe(self.predictions, title="Predictions")

BacktestResult

Bases: DisplayMixin, BaseModel

Result of the backtest workflow.

Attributes:

Name Type Description
profile ForecastingProfile

Profile of the input dataset and high-level modeling decisions.

plan ForecastPlan

Detailed forecasting plan that was executed.

cv_config dict

Resolved TimeSeriesFold parameters for traceability.

metrics pandas DataFrame

Backtesting metric values returned by skforecast.

predictions pandas DataFrame

Full backtest predictions across all folds.

code str

Generated Python script reproducing the backtesting workflow.

explanation str

Human-readable explanation of the backtesting configuration and results summary.

Attributes
model_config class-attribute instance-attribute
model_config = ConfigDict(arbitrary_types_allowed=True)
profile instance-attribute
profile
plan instance-attribute
plan
cv_config instance-attribute
cv_config
metrics instance-attribute
metrics
predictions instance-attribute
predictions
code instance-attribute
code
explanation instance-attribute
explanation
Functions
_rich_body
_rich_body(console, options)
Source code in skforecast_ai/schemas/results.py
161
162
163
164
165
166
167
168
169
def _rich_body(
    self, console: Console, options: ConsoleOptions
) -> RenderResult:
    yield render_explanation(self.explanation)
    yield render_cv_config(self.cv_config)
    yield render_metrics(self.metrics, title="Backtest Metrics")
    yield render_dataframe(self.predictions, title="Backtest Predictions")
    yield render_profile(self.profile)
    yield render_plan(self.plan)

AskResult

Bases: DisplayMixin, BaseModel

Result of the ask workflow (requires LLM).

Attributes:

Name Type Description
profile ForecastingProfile, default None

Profile of the input dataset and high-level modeling decisions, if data was provided.

plan ForecastPlan, default None

Detailed forecasting plan, if the agent produced one.

code str, default None

Generated Python script, if the agent produced one.

explanation str

LLM-generated explanation or response.

Attributes
profile class-attribute instance-attribute
profile = None
plan class-attribute instance-attribute
plan = None
code class-attribute instance-attribute
code = None
explanation instance-attribute
explanation
Functions
_rich_body
_rich_body(console, options)
Source code in skforecast_ai/schemas/results.py
194
195
196
197
def _rich_body(
    self, console: Console, options: ConsoleOptions
) -> RenderResult:
    yield render_explanation(self.explanation, title="Assistant Response")

Functions