-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added model diagnostic charts * added results conversion for BayesOptimization and Optuna libraries
- Loading branch information
1 parent
e02a890
commit e9e6ad7
Showing
12 changed files
with
683 additions
and
148 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 |
---|---|---|
@@ -0,0 +1,188 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Log model diagnostics to Neptune\n", | ||
"## Train your model and run predictions\n", | ||
"Let's train a model on a synthetic problem predict on test data." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from sklearn.datasets import make_classification\n", | ||
"from sklearn.ensemble import RandomForestClassifier\n", | ||
"from sklearn.model_selection import train_test_split\n", | ||
"from sklearn.metrics import classification_report\n", | ||
"\n", | ||
"X, y = make_classification(n_samples=2000)\n", | ||
"\n", | ||
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", | ||
"\n", | ||
"model = RandomForestClassifier()\n", | ||
"model.fit(X_train, y_train)\n", | ||
"\n", | ||
"y_test_pred = model.predict_proba(X_test)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Instantiate Neptune" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import neptune\n", | ||
"\n", | ||
"ctx = neptune.Context()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Send classification report to Neptune" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from neptunecontrib.monitoring.reporting import send_binary_classification_report\n", | ||
"\n", | ||
"send_binary_classification_report(ctx, y_test, y_test_pred, threshold=0.5)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"It is now safely logged in Neptune\n", | ||
"\n", | ||
"![image1](https://gist.githubusercontent.com/jakubczakon/f754769a39ea6b8fa9728ede49b9165c/raw/a1386b3a5edddc0eecb478a81d497336156b5b19/clf_report1.png)\n", | ||
"\n", | ||
"## Send confusion matrix to Neptune" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from neptunecontrib.monitoring.reporting import send_confusion_matrix\n", | ||
"\n", | ||
"send_confusion_matrix(ctx, y_test, y_test_pred[:, 1] > 0.5)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"It is now safely logged in Neptune\n", | ||
"\n", | ||
"![image2](https://gist.githubusercontent.com/jakubczakon/f754769a39ea6b8fa9728ede49b9165c/raw/a1386b3a5edddc0eecb478a81d497336156b5b19/clf_report4.png)\n", | ||
"\n", | ||
"## Send ROC AUC curve to Neptune" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from neptunecontrib.monitoring.reporting import send_roc_auc_curve\n", | ||
"\n", | ||
"send_roc_auc_curve(ctx, y_test, y_test_pred)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"It is now safely logged in Neptune\n", | ||
"\n", | ||
"![image3](https://gist.githubusercontent.com/jakubczakon/f754769a39ea6b8fa9728ede49b9165c/raw/a1386b3a5edddc0eecb478a81d497336156b5b19/clf_report3.png)\n", | ||
"\n", | ||
"## Send Precision-Recall curve to Neptune" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from neptunecontrib.monitoring.reporting import send_precision_recall\n", | ||
"\n", | ||
"send_prediction_distribution(y_test, y_test_pred)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"It is now safely logged in Neptune\n", | ||
"\n", | ||
"![image4](https://gist.githubusercontent.com/jakubczakon/f754769a39ea6b8fa9728ede49b9165c/raw/a1386b3a5edddc0eecb478a81d497336156b5b19/clf_report5.png)\n", | ||
"\n", | ||
"## Send Precision-Recall curve to Neptune" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from neptunecontrib.monitoring.reporting import send_prediction_distribution\n", | ||
"\n", | ||
"send_prediction_distribution(y_test, y_test_pred[:, 1])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"It is now safely logged in Neptune\n", | ||
"\n", | ||
"![image5](https://gist.githubusercontent.com/jakubczakon/f754769a39ea6b8fa9728ede49b9165c/raw/a1386b3a5edddc0eecb478a81d497336156b5b19/clf_report2.png)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "santander", | ||
"language": "python", | ||
"name": "santander" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.8" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
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,6 @@ | ||
Reporting | ||
=========== | ||
|
||
.. automodule:: neptunecontrib.monitoring.reporting | ||
:members: | ||
:show-inheritance: |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.