manager.multitask.run

manager.multitask.run(
    dataframe=None,
    task='lazy',
    cache_home=None,
    bounds=None,
    agg_weights=None,
    project_name='test_project',
    n_trials_optuna=10,
    train_days=3 * 365,
    val_days=31,
    imputation_method='weighted',
    show_progress=False,
    plot_with_outliers=False,
    show=False,
    verbose=False,
    log_level=40,
    **kwargs,
)

Run the MultiTask forecasting pipeline and return predictions.

Wraps the standard pipeline sequence into a single call. For the "clean" task only the cache directory is wiped and an empty DataFrame is returned. For all other tasks the full sequence

prepare_data → detect_outliers → impute →
build_exogenous_features → run

is executed and the aggregated future predictions are returned as a DataFrame.

Parameters

Name Type Description Default
dataframe pd.DataFrame Input time-series data. Must contain a datetime column matching the configured index_name and at least one numeric target column. Optional for the "clean" task, but required for all other tasks. Defaults to None. None
task str Pipeline mode — one of "lazy", "optuna", "spotoptim", "predict", or "clean". Defaults to "lazy". 'lazy'
cache_home Optional[str] Optional path to the cache directory. Defaults to None, which uses the package default cache location that is defined via spotforecast2_safe’s get_cache_home(). None
bounds Optional[List[Tuple[float, float]]] Per-column hard outlier bounds as a list of (lower, upper) tuples, one per target column. None uses the package defaults. None
agg_weights Optional[List[float]] Per-column weights for the final aggregation step as a list of floats, one per target column. None uses the package defaults. None
project_name str Identifier used for cache-directory and model-file naming. Defaults to "test_project". 'test_project'
train_days Optional[int] Optional number of days in the training window. Defaults to 3 years (1095 days). 3 * 365
val_days Optional[int] Optional number of days in the validation window. If None, the default of 31 days is used. 31
imputation_method str Method used for imputation of detected outliers. Passed to the imputation_method argument of MultiTask. Options are "weighted" or "linear". Defaults to "weighted". Prefer "weighted" (Gap Weighting) for data with leading or trailing gaps: it forward/back-fills the frame and emits a weight series that zero-weights samples within window_size of any original gap, so the forecaster never trains on the fill values. "linear" only fills internal gaps and lets endpoint NaN survive, so the downstream fit raises ValueError if leading or trailing NaN remain. 'weighted'
show_progress bool Whether to print progress messages during pipeline execution. Defaults to False. False
plot_with_outliers bool Whether to generate a visualization of the data with outliers highlighted. Defaults to False. False
show bool Whether to display prediction figures after running each task. Defaults to False. False
verbose bool Default is False. False
log_level int Logging level. Default is 40 (ERROR). Other common values include 0 (NOTSET), 10 (DEBUG), 20 (INFO), 30 (WARNING), 50 (CRITICAL). 40
**kwargs Any Additional keyword arguments forwarded verbatim to MultiTask. {}

Returns

Name Type Description
DataFrame pd.DataFrame DataFrame whose index is the forecast horizon timestamps and whose single column "forecast" contains the aggregated predicted values. For the "clean" task an empty DataFrame is returned.

Raises

Name Type Description
ValueError If task is not one of the supported task names.

Examples

Run the pipeline using cached or default model parameters ("lazy" task):

from spotforecast2.manager.multitask.runner import run
from spotforecast2_safe.data.fetch_data import fetch_data, get_package_data_home
import warnings
warnings.filterwarnings("ignore")

data_home = get_package_data_home()
df = fetch_data(filename=str(data_home / "demo02.csv"))

forecast = run(df, task="lazy", project_name="demo02", train_days = 365, predict_size=24, imputation_method="weighted")
print(forecast)
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
                             forecast
1975-06-18 19:00:00+00:00 -111.440887
1975-06-18 20:00:00+00:00   25.984569
1975-06-18 21:00:00+00:00  -45.674672
1975-06-18 22:00:00+00:00   33.965587
1975-06-18 23:00:00+00:00  171.503273
1975-06-19 00:00:00+00:00  118.253563
1975-06-19 01:00:00+00:00   91.917397
1975-06-19 02:00:00+00:00   56.067265
1975-06-19 03:00:00+00:00    0.392011
1975-06-19 04:00:00+00:00  -70.641445
1975-06-19 05:00:00+00:00 -109.984629
1975-06-19 06:00:00+00:00 -106.987940
1975-06-19 07:00:00+00:00  -95.128490
1975-06-19 08:00:00+00:00  -83.148436
1975-06-19 09:00:00+00:00 -102.156701
1975-06-19 10:00:00+00:00  -80.464212
1975-06-19 11:00:00+00:00 -111.926806
1975-06-19 12:00:00+00:00 -123.424511
1975-06-19 13:00:00+00:00  -92.054340
1975-06-19 14:00:00+00:00  -70.155662
1975-06-19 15:00:00+00:00 -112.164955
1975-06-19 16:00:00+00:00 -108.203508
1975-06-19 17:00:00+00:00 -105.346184
1975-06-19 18:00:00+00:00  -78.530332

Tune hyperparameters via Optuna Bayesian search ("optuna" task):

from spotforecast2.manager.multitask.runner import run
from spotforecast2_safe.data.fetch_data import fetch_data, get_package_data_home
import warnings
warnings.filterwarnings("ignore")

data_home = get_package_data_home()
df = fetch_data(filename=str(data_home / "demo02.csv"))

forecast = run(
    df,
    task="optuna",
    project_name="demo02",
    n_trials_optuna=5,
    predict_size=24,
    train_days=365,
    val_days=7,
    imputation_method="weighted"
)
print(forecast)
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
WeightFunction: all sample weights for the requested index are zero (the window falls entirely within gap-penalty zones). Returning None so ForecasterRecursive uses uniform weighting.
                             forecast
1975-06-18 19:00:00+00:00  -50.249274
1975-06-18 20:00:00+00:00   94.919682
1975-06-18 21:00:00+00:00   34.158562
1975-06-18 22:00:00+00:00  -85.819358
1975-06-18 23:00:00+00:00  -56.212889
1975-06-19 00:00:00+00:00  142.544519
1975-06-19 01:00:00+00:00  128.809284
1975-06-19 02:00:00+00:00   94.377853
1975-06-19 03:00:00+00:00   10.486095
1975-06-19 04:00:00+00:00  -20.784942
1975-06-19 05:00:00+00:00  -46.127539
1975-06-19 06:00:00+00:00  -79.824495
1975-06-19 07:00:00+00:00 -116.801473
1975-06-19 08:00:00+00:00 -103.449925
1975-06-19 09:00:00+00:00  -62.778142
1975-06-19 10:00:00+00:00  -38.637466
1975-06-19 11:00:00+00:00  -97.416968
1975-06-19 12:00:00+00:00 -108.393945
1975-06-19 13:00:00+00:00  -79.918142
1975-06-19 14:00:00+00:00  -73.579668
1975-06-19 15:00:00+00:00 -110.497369
1975-06-19 16:00:00+00:00 -119.831727
1975-06-19 17:00:00+00:00  -90.260173
1975-06-19 18:00:00+00:00  -91.861492

Load previously saved models and predict without retraining ("predict" task). A prior training run ("lazy" or "optuna") must have saved models to the cache first:

from spotforecast2.manager.multitask.runner import run
from spotforecast2_safe.data.fetch_data import fetch_data, get_package_data_home
import warnings
warnings.filterwarnings("ignore")

data_home = get_package_data_home()
df = fetch_data(filename=str(data_home / "demo02.csv"))

forecast = run(df, task="predict", project_name="demo02", predict_size=24, imputation_method="weighted")
print(forecast)
                             forecast
1975-06-18 19:00:00+00:00  -50.249274
1975-06-18 20:00:00+00:00   94.919682
1975-06-18 21:00:00+00:00   34.158562
1975-06-18 22:00:00+00:00  -85.819358
1975-06-18 23:00:00+00:00  -56.212889
1975-06-19 00:00:00+00:00  142.544519
1975-06-19 01:00:00+00:00  128.809284
1975-06-19 02:00:00+00:00   94.377853
1975-06-19 03:00:00+00:00   10.486095
1975-06-19 04:00:00+00:00  -20.784942
1975-06-19 05:00:00+00:00  -46.127539
1975-06-19 06:00:00+00:00  -79.824495
1975-06-19 07:00:00+00:00 -116.801473
1975-06-19 08:00:00+00:00 -103.449925
1975-06-19 09:00:00+00:00  -62.778142
1975-06-19 10:00:00+00:00  -38.637466
1975-06-19 11:00:00+00:00  -97.416968
1975-06-19 12:00:00+00:00 -108.393945
1975-06-19 13:00:00+00:00  -79.918142
1975-06-19 14:00:00+00:00  -73.579668
1975-06-19 15:00:00+00:00 -110.497369
1975-06-19 16:00:00+00:00 -119.831727
1975-06-19 17:00:00+00:00  -90.260173
1975-06-19 18:00:00+00:00  -91.861492

Remove all cached models and artefacts for a project ("clean" task). Returns an empty DataFrame:

from spotforecast2.manager.multitask.runner import run

result = run(task="clean", project_name="demo02")
print(result.empty)
[clean] Cache removed successfully: /home/runner/.spotforecast2_cache
True