skforecast-ai

v0.5.0
io.github.skforecast/skforecast-ai Checked 1 hour ago Published 19 days ago

Forecast 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.

ParameterTypeDescription
data_path *stringAbsolute path of a CSV file ('.csv', '.tsv', '.csv.gz' or '.tsv.gz') inside the directory the server may read. URLs are not accepted.
date_columnColumn with the dates. When null, the first column holding dates is used.
dayfirstOrder 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…
decimalDecimal mark of the file: '.' or ',' (only when the separator is not ','). When null, it is detected from the file.
exog_columnsColumns 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.
sepSeparator 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_columnColumn with the series ids of long multi-series data.
targetColumn 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…
thousandsThousands 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`.

ParameterTypeDescription
profile_id *stringId returned by `profile`.
steps *integerForecast horizon: number of steps ahead to predict, from 1 to the length of the longest series (12 for a year of monthly data).
calendar_featuresCalendar 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…
differentiationOrder 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_seriesWhether 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.
estimatorEstimator: one of ['CatBoostRegressor', 'HistGradientBoostingRegressor', 'LGBMRegressor', 'RandomForestRegressor', 'Ridge', 'XGBRegressor'] for the machine learning forecasters, 'Arima' for Forecaster…
estimator_kwargsKeyword 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…
forecasterskforecast forecaster class: ForecasterRecursive or ForecasterDirect (one series, machine learning), ForecasterRecursiveMultiSeries (several series), ForecasterDirectMultiVariate (one series predicted…
intervalPrediction 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…
lagsLags: an integer n for 1..n, or a list of distinct positive integers. Null for the selection from the partial autocorrelation.
metricMetric, 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_transformerScaler of the target: 'StandardScaler', or 'none' for no scaling. Machine learning forecasters only. Null for the rule.
use_exogWhether 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_featuresRolling 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.

ParameterTypeDescription
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 *stringId 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.

ParameterTypeDescription
plan_id *stringId of the plan to backtest (from `plan` or `refine_plan`).
allow_incomplete_foldWhether the last fold may have fewer than `steps` observations. Null for true.
fixed_train_sizeWhether 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_strideObservations the test set advances between folds. Null for `steps` (back-to-back folds); a larger value means fewer folds.
gapObservations 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_sizeObservations 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…
refitWhether 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_foldsFolds 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.

ParameterTypeDescription
cv_id *stringId returned by `create_cv`.
confirm_costConfirms 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_idPlan 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.

ParameterTypeDescription
cv_id *stringId returned by `create_cv`: every candidate is backtested on its folds.
baselinebooleanWhether to add a seasonal naive baseline (ForecasterEquivalentDate) to the ranking.
candidatesConfigurations 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_costConfirms 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…
intervalPrediction 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…
metricMetric 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.

ParameterTypeDescription
plan_id *stringId of the plan to run (from `plan`, `refine_plan` or `links.best_plan_id` of `compare`).
exog_pathAbsolute 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_sizeNull 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`.

ParameterTypeDescription
object_id *stringId 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).
candidateFor 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`.

ParameterTypeDescription
object_id *string`details.failure_id` of an error, or the id of a comparison whose candidate failed.
candidateName 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.

ParameterTypeDescription
kindOnly 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`.

ParameterTypeDescription
object_id *stringId of a registered object.