OLSModel
OLSModel
Ordinary Least Squares linear regression using scikit-learn’s LinearRegression.
Basic Usage
from epftoolbox2.models import OLSModel
model = OLSModel( predictors=[ "load_actual", "is_monday_d+{horizon}", "is_tuesday_d+{horizon}", "is_wednesday_d+{horizon}", "is_thursday_d+{horizon}", "is_friday_d+{horizon}", "is_saturday_d+{horizon}", "is_sunday_d+{horizon}", "is_holiday_d+{horizon}", "daylight_hours_d+{horizon}", ], training_window=365, name="OLS",)Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
predictors | List | Required | Predictor specifications |
training_window | int | 365 | Days of training data |
name | str | "Model" | Display name for reports |
Example
from epftoolbox2.pipelines import ModelPipelinefrom epftoolbox2.models import OLSModelfrom epftoolbox2.evaluators import MAEEvaluatorfrom epftoolbox2.exporters import TerminalExporter
predictors = [ "load_actual", "is_monday_d+{horizon}", "is_tuesday_d+{horizon}", "is_wednesday_d+{horizon}", "is_thursday_d+{horizon}", "is_friday_d+{horizon}", "is_saturday_d+{horizon}", "is_sunday_d+{horizon}", "is_holiday_d+{horizon}", "daylight_hours_d+{horizon}", *[f"load_actual_d-{i}" for i in [1, 7]],]
pipeline = ( ModelPipeline() .add_model(OLSModel(predictors=predictors, name="OLS")) .add_evaluator(MAEEvaluator()) .add_exporter(TerminalExporter()))
report = pipeline.run(data=df, test_start="2024-02-01", test_end="2024-03-01")