-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ADD model registration * codespell * ADD test * ADD lastest for #105 * Bug fix scoring using dict with registered scorer * Add overwrite to register_models * Adjust transformer to make overwrite consistent * Make registering more consistent * flake8 * latest * codespell * Correct Docs
- Loading branch information
1 parent
3a3fd9a
commit 11911cc
Showing
13 changed files
with
245 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de> | ||
# Sami Hamdan <s.hamdan@fz-juelich.de> | ||
# License: AGPL | ||
from . available_models import list_models, get_model | ||
from . available_models import (list_models, get_model, | ||
register_model, reset_model_register) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de> | ||
# Sami Hamdan <s.hamdan@fz-juelich.de> | ||
# Shammi More <s.more@fz-juelich.de> | ||
# License: AGPL | ||
|
||
import pytest | ||
from julearn.estimators import register_model, reset_model_register, get_model | ||
from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor | ||
from sklearn.ensemble import RandomForestRegressor | ||
|
||
|
||
def test_register_model(): | ||
register_model("dt", | ||
binary_cls=DecisionTreeClassifier, | ||
multiclass_cls=DecisionTreeClassifier, | ||
regression_cls=DecisionTreeRegressor | ||
) | ||
binary = get_model("dt", "binary_classification") | ||
multiclass = get_model("dt", "multiclass_classification") | ||
regression = get_model("dt", "regression") | ||
|
||
assert isinstance(binary, DecisionTreeClassifier) | ||
assert isinstance(multiclass, DecisionTreeClassifier) | ||
assert isinstance(regression, DecisionTreeRegressor) | ||
reset_model_register() | ||
|
||
with pytest.raises(ValueError, match="The specified model "): | ||
binary = get_model("dt", "binary_classification") | ||
|
||
|
||
def test_register_warning(): | ||
with pytest.warns(RuntimeWarning, match="Model name"): | ||
register_model("rf", regression_cls=RandomForestRegressor) | ||
reset_model_register() | ||
|
||
with pytest.raises(ValueError, match="Model name"): | ||
register_model( | ||
"rf", regression_cls=RandomForestRegressor, overwrite=False) | ||
reset_model_register() | ||
|
||
with pytest.warns(None) as record: | ||
register_model( | ||
"rf", regression_cls=RandomForestRegressor, overwrite=True) | ||
reset_model_register() | ||
assert len(record) == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.