Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institut für Informatik
dbis
software
dbispipeline
Commits
446e9cfd
Commit
446e9cfd
authored
Sep 10, 2021
by
Benjamin Murauer
Browse files
fixed test for storing callback results in evaluator
parent
b73c4b37
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
src/dbispipeline/evaluators.py
src/dbispipeline/evaluators.py
+4
-2
tests/evaluators/test_model_storing.py
tests/evaluators/test_model_storing.py
+1
-1
No files found.
src/dbispipeline/evaluators.py
View file @
446e9cfd
...
...
@@ -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
,
}
...
...
tests/evaluators/test_model_storing.py
View file @
446e9cfd
...
...
@@ -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_result
s
[
'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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment