Skip to content

Commit

Permalink
Merge pull request #6 from dotmesh-io/docs
Browse files Browse the repository at this point in the history
NFC: add model call to sklearn tutorial
  • Loading branch information
Charlotte Godley committed Dec 3, 2019
2 parents 8fed970 + 2d91b84 commit 48f310b
Showing 1 changed file with 6 additions and 14 deletions.
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
}

0 comments on commit 48f310b

Please sign in to comment.