ModelPerformanceCallback#
- class openstef_models.workflows.callbacks.model_performance_callback.ModelPerformanceCallback(*, metric_name: str, threshold: float, metric_direction: MetricDirection, quantile: Union[Quantile, Literal['global']] = 'global')[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:
- metric_name: str
- threshold: float
- metric_direction: MetricDirection
- 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.
- Raises:
ModelUnderperformingError – If the model’s performance metric is below the defined threshold.
- Return type:
- Overrides:
PredictorCallback.on_fit_end
- 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].