configurator.config_demo.ConfigDemo(
data_path= (lambda : get_package_data_home() / 'demo11.csv' )(),
model_root= (lambda : Path.home() / 'spotforecast2_safe_models' )(),
log_root= (lambda : Path.home() / 'spotforecast2_safe_models' / 'logs' )(),
forecast_horizon= 24 ,
contamination= 0.01 ,
window_size= 72 ,
lags= 24 ,
train_ratio= 0.8 ,
random_seed= 42 ,
weights= (lambda : [1.0 , 1.0 , - 1.0 , - 1.0 , 1.0 , - 1.0 , 1.0 , 1.0 , 1.0 , - 1.0 , 1.0 ])(),
)
Configuration for the safety-critical demo task.
This immutable dataclass encapsulates all parameters needed for forecasting demonstrations, including data paths, model directories, and hyperparameters. All fields have sensible defaults but can be overridden during initialization.
Attributes
data_path
Path
Path to the ground truth CSV file for testing.
model_root
Path
Root directory for storing trained models.
log_root
Path
Directory for storing log files.
forecast_horizon
int
Number of time steps to forecast ahead.
contamination
float
Contamination factor for outlier detection (0.0-1.0).
window_size
int
Size of the sliding window for feature extraction.
lags
int
Number of lagged features to include.
train_ratio
float
Ratio of data used for training (0.0-1.0).
random_seed
int
Random seed for reproducibility.
weights
List [float ]
Weights for aggregating multi-variable predictions.
Examples
Default configuration:
from spotforecast2_safe.configurator import ConfigDemo
config = ConfigDemo()
print (f"Forecast horizon: { config. forecast_horizon} " )
print (f"Window size: { config. window_size} " )
print (f"Random seed: { config. random_seed} " )
Forecast horizon: 24
Window size: 72
Random seed: 42
Override specific parameters:
from spotforecast2_safe.configurator import ConfigDemo
config = ConfigDemo(forecast_horizon= 48 , contamination= 0.05 , random_seed= 123 )
print (f"Forecast horizon: { config. forecast_horizon} " )
print (f"Contamination: { config. contamination} " )
Forecast horizon: 48
Contamination: 0.05
Customize paths for a specific environment:
import tempfile
from pathlib import Path
from spotforecast2_safe.configurator import ConfigDemo
with tempfile.TemporaryDirectory() as tmpdir:
custom_config = ConfigDemo(
data_path= Path(tmpdir) / "my_data.csv" ,
model_root= Path(tmpdir) / "models" ,
log_root= Path(tmpdir) / "logs" ,
)
print (f"Data path name: { custom_config. data_path. name} " )
print (f"Model root name: { custom_config. model_root. name} " )
Data path name: my_data.csv
Model root name: models
Custom weights for multi-variable aggregation:
from spotforecast2_safe.configurator import ConfigDemo
config = ConfigDemo(weights= [1.0 , 1.0 , - 1.0 , 1.0 , 1.0 ])
print (f"Number of weights: { len (config.weights)} " )
Immutability check (frozen dataclass):
from spotforecast2_safe.configurator import ConfigDemo
config = ConfigDemo()
try :
config.forecast_horizon = 100
except AttributeError :
print ("Config is immutable as expected" )
Config is immutable as expected
Production configuration with a long horizon:
from spotforecast2_safe.configurator import ConfigDemo
prod_config = ConfigDemo(
forecast_horizon= 168 , # 1 week
window_size= 336 , # 2 weeks
lags= 48 ,
train_ratio= 0.9 ,
contamination= 0.005 ,
)
print (f"Production horizon: { prod_config. forecast_horizon} hours" )
print (f"Training ratio: { prod_config. train_ratio} " )
Production horizon: 168 hours
Training ratio: 0.9