Commit b73c4b37 authored by Benjamin Murauer's avatar Benjamin Murauer
Browse files

allow multiple callbacks for callback wrapping evaluator

parent 4394a0d6
Pipeline #51362 failed with stage
in 1 minute and 46 seconds
......@@ -56,7 +56,10 @@ class ModelCallbackWrapper(Evaluator):
f'the wrapped evaluator {wrapped_evaluator.__class__.__name__}'
'does not have a fitted_model attribute.')
self.wrapped_evaluator = wrapped_evaluator
self.callback = callback
if not type(callback) == list:
self.callbacks = [callback]
self.callbacks = callback
self.callback_args = callback_args
self.callback_kwargs = callback_kwargs
......@@ -73,16 +76,15 @@ class ModelCallbackWrapper(Evaluator):
result = self.wrapped_evaluator.evaluate(model, data)
fitted_model = self.wrapped_evaluator.fitted_model
self.callback_result_ = self.callback(fitted_model,
for callback in self.callbacks:
callback(fitted_model, *self.callback_args, **self.callback_kwargs)
return result
def configuration(self):
"""A json-like representation of the configuration."""
return {
'model_callback': self.callback.__name__,
'model_callback': self.callbacks.__name__,
'wrapped_evaluator': self.wrapped_evaluator.__class__.__name__,
'wrapped_configuration': self.wrapped_evaluator.configuration,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment