multitask.strategies.DefaultsStrategy

multitask.strategies.DefaultsStrategy()

Approach 2 — Train with defaults, no tuning, no cached params.

The simplest possible training strategy: leave the forecaster at the parameters produced by the factory and hand it back to _train_and_predict_target for the explicit fit. Use this when the caller wants a deterministic baseline that does not benefit from any cached tuning results — useful for ENTSO-E “Approach 2: Training without Tuning” and for regression benchmarking.

Functionally equivalent to LazyStrategy(use_tuned_params=False); kept as a distinct class so the task="defaults" routing reads intent at the call site (no implicit cache lookup).

Examples

import pandas as pd
from sklearn.linear_model import LinearRegression
from spotforecast2_safe.forecaster.recursive import ForecasterRecursive
from spotforecast2_safe.multitask.strategies import DefaultsStrategy

strategy = DefaultsStrategy()
assert strategy.name == "defaults"
print(f"strategy.name={strategy.name!r}")

forecaster = ForecasterRecursive(estimator=LinearRegression(), lags=5)
y_train = pd.Series(range(30), dtype=float, name="target_0")

class _NullTask:
    pass

result = strategy.prepare_forecaster(_NullTask(), "target_0", forecaster, y_train)
assert result is forecaster
assert list(result.lags) == [1, 2, 3, 4, 5], f"Unexpected lags: {list(result.lags)}"
print(f"Forecaster returned unchanged: lags={list(result.lags)}")
strategy.name='defaults'
Forecaster returned unchanged: lags=[np.int64(1), np.int64(2), np.int64(3), np.int64(4), np.int64(5)]

Methods

Name Description
prepare_forecaster Return the forecaster unchanged — no tuning, no cached params.

prepare_forecaster

multitask.strategies.DefaultsStrategy.prepare_forecaster(
    task,
    target,
    forecaster,
    y_train,
    exog_train=None,
)

Return the forecaster unchanged — no tuning, no cached params.

Parameters

Name Type Description Default
task Any Ignored; accepted for protocol compatibility. required
target str Ignored; accepted for protocol compatibility. required
forecaster Any The unfitted forecaster returned by the factory. required
y_train pd.Series Ignored; accepted for protocol compatibility. required
exog_train Optional[pd.DataFrame] Ignored; accepted for protocol compatibility. None

Returns

Name Type Description
Any The same forecaster object, unmodified.

Examples

import pandas as pd
from sklearn.linear_model import LinearRegression
from spotforecast2_safe.forecaster.recursive import ForecasterRecursive
from spotforecast2_safe.multitask.strategies import DefaultsStrategy

forecaster = ForecasterRecursive(estimator=LinearRegression(), lags=3)
y_train = pd.Series(range(30), dtype=float, name="target_0")

class _NullTask:
    pass

strategy = DefaultsStrategy()
result = strategy.prepare_forecaster(_NullTask(), "target_0", forecaster, y_train)
assert result is forecaster
print(f"Returned same forecaster object: {result is forecaster}")
print(f"Lags unchanged: {list(result.lags)}")
Returned same forecaster object: True
Lags unchanged: [np.int64(1), np.int64(2), np.int64(3)]