ModelPerformanceCallback#
- class openstef_models.workflows.callbacks.ModelPerformanceCallback(**data: Any) None[source]
Bases:
BaseConfig,ForecastingCallbackCallback for comparing model performance against a treshold during the fit process.
This callback evaluates the model’s performance using a specified metric after fitting. If the performance metric does not meet the defined threshold, a ModelUnderperformingError is raised.
- Parameters:
data (
Any)
-
metric_name:
str
-
threshold:
float
-
metric_direction:
TypeAliasType
- on_fit_end(context: WorkflowContext[CustomForecastingWorkflow], result: ModelFitResult) None[source]
Evaluate model performance at the end of fitting and raise an error if underperforming.
- Parameters:
context (
WorkflowContext[CustomForecastingWorkflow]) – The workflow context that completed fitting.result (
ModelFitResult) – Result of the fitting process containing performance metrics.context
result
- Raises:
ModelUnderperformingError – If the model’s performance metric is below the defined threshold.
- Return type:
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': False, 'extra': 'ignore', 'protected_namespaces': ()}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].