Commit 446e9cfd authored by Benjamin Murauer's avatar Benjamin Murauer
Browse files

fixed test for storing callback results in evaluator

parent b73c4b37
......@@ -62,6 +62,7 @@ class ModelCallbackWrapper(Evaluator):
self.callbacks = callback
self.callback_args = callback_args
self.callback_kwargs = callback_kwargs
self.callback_results = {}
def evaluate(self, model, data):
"""
......@@ -77,16 +78,17 @@ class ModelCallbackWrapper(Evaluator):
result = self.wrapped_evaluator.evaluate(model, data)
fitted_model = self.wrapped_evaluator.fitted_model
for callback in self.callbacks:
callback(fitted_model, *self.callback_args, **self.callback_kwargs)
self.callback_results[callback.__name__] = callback(
fitted_model, *self.callback_args, **self.callback_kwargs)
return result
@property
def configuration(self):
"""A json-like representation of the configuration."""
return {
'model_callback': self.callbacks.__name__,
'wrapped_evaluator': self.wrapped_evaluator.__class__.__name__,
'wrapped_configuration': self.wrapped_evaluator.configuration,
'callbacks': self.callback_results,
}
......
......@@ -22,7 +22,7 @@ def test_model_store_evaluator():
pickle_model_callback,
output_path=tmp.name)
evaluator.evaluate(pipeline, data)
actual_filename = evaluator.callback_result_
actual_filename = evaluator.callback_results['pickle_model_callback']
with open(actual_filename, 'rb') as i_f:
model = pickle.load(i_f)
# the equality of the SVM weights should suffice as valid indicator.
......
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