multitask.defaults.DefaultsTask

multitask.defaults.DefaultsTask(
    config=None,
    *,
    dataframe=None,
    data_test=None,
    cache_home=None,
    log_level=logging.INFO,
    **overrides,
)

Task 2 — Defaults fitting (no tuning, no cached params).

Creates an unfitted forecaster per target via config.forecaster_factory (or the package default) and fits with whatever parameters that factory chooses. Unlike LazyTask, never reads the tuning-result cache.

Examples

import tempfile
from pathlib import Path
from spotforecast2_safe.multitask import DefaultsTask
from spotforecast2_safe.configurator.config_multi import ConfigMulti

with tempfile.TemporaryDirectory() as tmp:
    cfg = ConfigMulti(data_frame_name="demo10", predict_size=24, cache_home=Path(tmp))
    task = DefaultsTask(cfg)
    print(f"Task: {task.TASK}")
    print(f"Predict size: {task.config.predict_size}")
Task: defaults
Predict size: 24

Methods

Name Description
run Run defaults fitting for all targets.

run

multitask.defaults.DefaultsTask.run(show=False, **kwargs)

Run defaults fitting for all targets.

Parameters

Name Type Description Default
show bool If True, invoke the visualisation hooks. False
**kwargs Any Forwarded for compatibility with BaseTask.run; DefaultsTask does not consume any extra parameters. {}

Returns

Name Type Description
Dict[str, Any] Aggregated prediction package. Per-target packages are stored
Dict[str, Any] on self.results["defaults"].

Examples

import tempfile
import numpy as np
import pandas as pd
from pathlib import Path
from spotforecast2_safe.multitask.defaults import DefaultsTask
from spotforecast2_safe.configurator.config_multi import ConfigMulti

rng = np.random.default_rng(0)
idx = pd.date_range("2023-01-01", periods=24 * 14, freq="h", tz="UTC")
df = pd.DataFrame({"load": rng.normal(100, 10, len(idx))}, index=idx)
df.index.name = "DateTime"

with tempfile.TemporaryDirectory() as tmp:
    cfg = ConfigMulti(
        predict_size=6,
        use_exogenous_features=False,
        use_outlier_detection=False,
        auto_save_models=False,
        number_folds=2,
        cache_home=Path(tmp),
        verbose=False,
    )
    task = DefaultsTask(cfg, dataframe=df)
    task.prepare_data().detect_outliers().impute().build_exogenous_features()
    result = task.run()

print(f"Future predictions: {len(result['future_pred'])} steps")
assert "defaults" in task.results
assert isinstance(result["future_pred"], pd.Series)
Future predictions: 6 steps