Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NFC: add model call to sklearn tutorial #6

Merged
merged 1 commit into from
Dec 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions sklearn-gridsearch/grid-search.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Hyperparamerter optimisation with Dotscience\n",
"\n",
Expand All @@ -17,6 +15,7 @@
"metadata": {},
"outputs": [],
"source": [
"import sklearn\n",
"from sklearn import datasets\n",
"from sklearn.model_selection import train_test_split\n",
"from sklearn.model_selection import GridSearchCV\n",
Expand All @@ -28,9 +27,7 @@
},
{
"cell_type": "markdown",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Let's load the digits dataset and apply a classifier on this data."
]
Expand All @@ -54,9 +51,7 @@
},
{
"cell_type": "markdown",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Split the dataset in two equal parts\n"
]
Expand All @@ -73,9 +68,7 @@
},
{
"cell_type": "markdown",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Set the parameters by cross-validation"
]
Expand All @@ -93,9 +86,7 @@
},
{
"cell_type": "markdown",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Let's tune hyper-parameters for the scores. \n",
"\n",
Expand Down Expand Up @@ -126,6 +117,7 @@
" print()\n",
" means = clf.cv_results_['mean_test_score']\n",
" stds = clf.cv_results_['std_test_score']\n",
" ds.sklearn_model(sklearn, clf, \"grid search\", \"model_%s.joblib\" % score)\n",
" for mean, std, params in zip(means, stds, clf.cv_results_['params']):\n",
" ds.start()\n",
" ds.add_parameters(**params)\n",
Expand All @@ -143,7 +135,6 @@
" print()\n",
" y_true, y_pred = y_test, clf.predict(X_test)\n",
" print(classification_report(y_true, y_pred))\n",
" print()\n",
"\n",
"# Note the problem is too easy: the hyperparameter plateau is too flat and the\n",
"# output model is the same for precision and recall with ties in quality."
Expand All @@ -166,9 +157,10 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.6.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
"nbformat_minor": 4
}