-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'AUTOML-49' into 'master'
[AUTOML-49] Model saving via joblib and delete joblib upper bound See merge request ai-lab-pmo/mltools/automl/LightAutoML!35
- Loading branch information
Showing
11 changed files
with
149 additions
and
116 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
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,30 @@ | ||
import numpy as np | ||
|
||
from lightautoml.dataset.roles import TargetRole | ||
from joblib import load | ||
|
||
from sklearn.metrics import log_loss | ||
from sklearn.metrics import mean_squared_error | ||
from sklearn.metrics import roc_auc_score | ||
|
||
|
||
def load_and_test_automl(filename, task, score, pred, data, target_name): | ||
automl = load(filename) | ||
|
||
test_pred_joblib = automl.predict(data) | ||
|
||
if task.name == "binary": | ||
score_new = roc_auc_score(data[target_name].values, test_pred_joblib.data[:, 0]) | ||
elif task.name == "multiclass": | ||
score_new = log_loss(data[target_name].map(automl.reader.class_mapping), test_pred_joblib.data) | ||
elif task.name == "reg": | ||
score_new = mean_squared_error(data[target_name].values, test_pred_joblib.data[:, 0]) | ||
|
||
np.testing.assert_almost_equal(score, score_new, decimal=3) | ||
np.testing.assert_allclose(pred.data[:, 0], test_pred_joblib.data[:, 0]) | ||
|
||
|
||
def get_target_name(roles): | ||
for key, value in roles.items(): | ||
if (key == "target") or isinstance(key, TargetRole): | ||
return value |
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.