skforecast-ai
v0.5.0Forecast time series in CSV files: deterministic skforecast workflows and the script that ran.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
profile
Profile a CSV file: frequency, series, exogenous columns and the recommended forecaster and estimator. The first step: returns a profile id, which `plan` takes.
| Parameter | Type | Description |
|---|---|---|
data_path * | string | Absolute path of a CSV file ('.csv', '.tsv', '.csv.gz' or '.tsv.gz') inside the directory the server may read. URLs are not accepted. |
date_column | Column with the dates. When null, the first column holding dates is used. | |
dayfirst | Order of the day and the month of the dates of the file: true for day first ('31/01/2024'), false for month first ('01/31/2024'). When null, it is told from the dates, or from their regularity with a… | |
decimal | Decimal mark of the file: '.' or ',' (only when the separator is not ','). When null, it is detected from the file. | |
exog_columns | Columns to use as exogenous variables, an empty list for none. When null, every column that is not the target, the date or the series ids. The other columns are not used. | |
sep | Separator of the fields of the file: ',', ';' or a tabulator. When null, it is detected from the file; pass it only when an error says it cannot be told. | |
series_id_column | Column with the series ids of long multi-series data. | |
target | Column to forecast, as the user named it, also when you are not sure it exists (an error then lists the columns of the file), or a list of columns (one series each) for wide multi-series data. Null on… | |
thousands | Thousands separator of the file: '.', with ',' as decimal mark (as in '1.705,11'). When null, it is detected from the file; pass it only when an error says it cannot be told. |
plan
Build a forecasting plan (lags, window features, metric, preprocessing, interval) from a profile id and a horizon. Returns a plan id, which `create_cv` and `forecast` take. To change a decision of an existing plan, use `refine_plan`.
| Parameter | Type | Description |
|---|---|---|
profile_id * | string | Id returned by `profile`. |
steps * | integer | Forecast horizon: number of steps ahead to predict, from 1 to the length of the longest series (12 for a year of monthly data). |
calendar_features | Calendar features generated from the dates (an empty list for none); the encoding follows the estimator. A feature whose column is already an exogenous column used by the plan is rejected. Machine lea… | |
differentiation | Order of differencing of the target before training (an integer of at least 1, usually 1 for a trend); predictions are integrated back. Machine learning forecasters only. Null for none. | |
dropna_from_series | Whether to drop the training rows with missing values; false fails when the data has missing values and the estimator does not accept them. Machine learning forecasters only. Null for the rule. | |
estimator | Estimator: one of ['CatBoostRegressor', 'HistGradientBoostingRegressor', 'LGBMRegressor', 'RandomForestRegressor', 'Ridge', 'XGBRegressor'] for the machine learning forecasters, 'Arima' for Forecaster… | |
estimator_kwargs | Keyword arguments of the estimator, e.g. {'n_estimators': 200}. A foundation model only takes context_length, cross_learning, point_estimate, max_horizon, add_calendar_features and n_fourier_terms. Nu… | |
forecaster | skforecast forecaster class: ForecasterRecursive or ForecasterDirect (one series, machine learning), ForecasterRecursiveMultiSeries (several series), ForecasterDirectMultiVariate (one series predicted… | |
interval | Prediction interval as two quantiles [lower, upper] with 0 < lower < upper < 1, e.g. [0.1, 0.9] for 80 %. The baseline and ForecasterStats only take symmetric ones (lower + upper = 1). Null for no int… | |
lags | Lags: an integer n for 1..n, or a list of distinct positive integers. Null for the selection from the partial autocorrelation. | |
metric | Metric, or list of metrics whose first one is the primary metric (the one that ranks); only the ones given are computed. Null for the metric selected from the data (MAE for one series, MASE for severa… | |
target_transformer | Scaler of the target: 'StandardScaler', or 'none' for no scaling. Machine learning forecasters only. Null for the rule. | |
use_exog | Whether to use the exogenous columns of the data: false leaves them out (forecast then takes no exog_path); true fails when the data has none or the forecaster cannot use them. Null uses them whenever… | |
window_features | Rolling features, one entry per window size: {'stats': [...], 'window_size': n}, with stats among ['mean', 'std', 'min', 'max', 'sum', 'median', 'ratio_min_max', 'coef_variation', 'ewm'], e.g. [{'stat… |
refine_plan
Build a new plan from an existing one, changing some of its decisions and keeping the others: use it instead of `plan` to change a plan. Returns a new plan id; the original plan is kept.
| Parameter | Type | Description |
|---|---|---|
overrides * | Values to change, e.g. {'estimator': 'Ridge', 'lags': 12}. An omitted key keeps the value of the plan, unless the new forecaster or estimator cannot take it: it is left out and a notice names it. {'la… | |
plan_id * | string | Id of the plan to refine. |
create_cv
Build a time series cross-validation strategy (TimeSeriesFold) for a plan id. Returns a cv id, which `backtest` and `compare` take, and its cost in `cost`: read it before running them.
| Parameter | Type | Description |
|---|---|---|
plan_id * | string | Id of the plan to backtest (from `plan` or `refine_plan`). |
allow_incomplete_fold | Whether the last fold may have fewer than `steps` observations. Null for true. | |
fixed_train_size | Whether the training window keeps its size when refitting (true) or grows (false). Null for false. Only with `refit` true or an integer: with `refit` false or null nothing is refitted, so it has no ef… | |
fold_stride | Observations the test set advances between folds. Null for `steps` (back-to-back folds); a larger value means fewer folds. | |
gap | Observations between the end of training and the test set. Null for 0. A direct forecaster (ForecasterDirect, ForecasterDirectMultiVariate) cannot be backtested with a gap. | |
initial_train_size | Observations of the first training set (a number), or the ISO 8601 date that ends it ('2005-06-01'). Null for the default: 70 % of the series, at least what the lags need and leaving room for two fold… | |
refit | Whether to train again in every fold (true), never (false) or every n folds (an integer). Null for false: train once. Refitting multiplies the cost; ForecasterStats is refitted in every fold whatever… | |
skip_folds | Folds are numbered from 0, and fold 0 always runs. An integer n keeps folds 0, n, 2n, ...; a list skips the folds at those numbers (each at least 1 and below the number of folds). Null for every fold.… |
backtest
Backtest one plan with a cv id of `create_cv`: metrics over the folds, with the predictions and metrics in CSV files named by the new id, so no run overwrites another. To rank several configurations, use `compare`. Returns a backtest id.
| Parameter | Type | Description |
|---|---|---|
cv_id * | string | Id returned by `create_cv`. |
confirm_cost | Confirms an expensive run (above 50 estimator fits, or 2000 inference windows of a foundation model), only once the user chose it: the number of its cost that `create_cv` or the error of a call withou… | |
plan_id | Plan to backtest, built from the same profile. Null for the plan the cross-validation strategy was built for. |
compare
Backtest several configurations on the folds of a cv id of `create_cv` and rank them by `metric`; for one plan, use `backtest`. Reports progress per candidate and can be cancelled between candidates. Returns a comparison id and the plan of the winner in `links.best_plan_id`, which `forecast` takes.
| Parameter | Type | Description |
|---|---|---|
cv_id * | string | Id returned by `create_cv`: every candidate is backtested on its folds. |
baseline | boolean | Whether to add a seasonal naive baseline (ForecasterEquivalentDate) to the ranking. |
candidates | Configurations to compare, each {'name': ..., 'config': {...}}, e.g. [{'name': 'ridge', 'config': {'estimator': 'Ridge'}}]. Null for the candidates recommended by the profile: the forecasters of its f… | |
confirm_cost | Confirms an expensive run (all the candidates together above 50 estimator fits, or 2000 inference windows of foundation models), only once the user chose it: the number of its cost that `create_cv` (w… | |
interval | Prediction interval computed for every candidate. Prediction interval as two quantiles [lower, upper] with 0 < lower < upper < 1, e.g. [0.1, 0.9] for 80 %. The baseline and ForecasterStats only take s… | |
metric | Metric of every candidate. Metric, or list of metrics whose first one is the primary metric (the one that ranks); only the ones given are computed. Null for the metric chosen for the plan the strategy… |
forecast
Run a plan: forecast the future, or evaluate on a test set with `test_size`. Predictions and metrics go to CSV files. A forecast of the future has no error measure: backtest or compare the plan first. Returns a forecast id.
| Parameter | Type | Description |
|---|---|---|
plan_id * | string | Id of the plan to run (from `plan`, `refine_plan` or `links.best_plan_id` of `compare`). |
exog_path | Absolute path of a CSV file with the future values of the exogenous variables, one row per date (and series) of the horizon, or for data without dates one row per step, in order. Required to forecast… | |
test_size | Null to forecast the future. To evaluate instead, the test set: the last n observations (an integer, which must equal `steps`) or the ISO 8601 date it starts at. A fraction in (0, 1) only works when i… |
get_code
Return the Python script of an object and the packages it needs: the one that ran, or that would run for a plan (a profile has none). For a run that failed, use `get_failure`.
| Parameter | Type | Description |
|---|---|---|
object_id * | string | Id of a plan (its forecasting script), a cross-validation strategy (the code that builds it), a backtest, a forecast or a comparison (the script that ran). |
candidate | For a comparison, the candidate whose script to return. Null for the best one. |
get_failure
Return the traceback and the code of a failed run (the `details.failure_id` of an error) or of a failed candidate of a comparison. The id of an object that did not fail is `invalid_argument`; for the script of a run that worked, use `get_code`.
| Parameter | Type | Description |
|---|---|---|
object_id * | string | `details.failure_id` of an error, or the id of a comparison whose candidate failed. |
candidate | Name of the failed candidate, required with the id of a comparison; null with a `failure_id`. |
list_objects
List the ids of the profiles, plans, strategies and runs the server keeps, most recently used first; beyond its limits the least recently used are removed, and none survives a restart. Use `describe_object` to read one.
| Parameter | Type | Description |
|---|---|---|
kind | Only the objects of this kind. Null for every kind. |
describe_object
Return again the response that created an object (summary, links, notices, files), from an id of any response or of `list_objects`.
| Parameter | Type | Description |
|---|---|---|
object_id * | string | Id of a registered object. |