mirror of
https://github.com/ArthurDanjou/handson-ml3.git
synced 2026-01-28 02:30:27 +01:00
Add notebooks for chapters 5 to 14
This commit is contained in:
@@ -4,7 +4,23 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Classification**"
|
||||
"**Chapter 3 – Classification**\n",
|
||||
"\n",
|
||||
"_This notebook contains all the sample code and solutions to the exercices in chapter 3._"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Setup"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"First, let's make sure this notebook works well in both python 2 and 3, import a few common modules, ensure MatplotLib plots figures inline and prepare a function to save the figures:"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -15,14 +31,18 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# To support both python 2 and python 3\n",
|
||||
"from __future__ import division, print_function, unicode_literals\n",
|
||||
"\n",
|
||||
"# Common imports\n",
|
||||
"import numpy as np\n",
|
||||
"import numpy.random as rnd\n",
|
||||
"rnd.seed(42) # to make this notebook's output stable across runs\n",
|
||||
"\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"# to make this notebook's output stable across runs\n",
|
||||
"rnd.seed(42)\n",
|
||||
"\n",
|
||||
"# To plot pretty figures\n",
|
||||
"%matplotlib inline\n",
|
||||
"import matplotlib\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
@@ -30,6 +50,7 @@
|
||||
"plt.rcParams['xtick.labelsize'] = 12\n",
|
||||
"plt.rcParams['ytick.labelsize'] = 12\n",
|
||||
"\n",
|
||||
"# Where to save the figures\n",
|
||||
"PROJECT_ROOT_DIR = \".\"\n",
|
||||
"CHAPTER_ID = \"classification\"\n",
|
||||
"\n",
|
||||
@@ -122,7 +143,7 @@
|
||||
"some_digit_index = 36000\n",
|
||||
"some_digit = X[some_digit_index]\n",
|
||||
"plot_digit(some_digit)\n",
|
||||
"save_fig(\"some_digit\")\n",
|
||||
"save_fig(\"some_digit_plot\")\n",
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
@@ -153,7 +174,7 @@
|
||||
"plt.figure(figsize=(9,9))\n",
|
||||
"example_images = np.r_[X[:12000:600], X[13000:30600:600], X[30600:60000:590]]\n",
|
||||
"plot_digits(example_images, images_per_row=10)\n",
|
||||
"save_fig(\"more_digits\")\n",
|
||||
"save_fig(\"more_digits_plot\")\n",
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
@@ -980,7 +1001,7 @@
|
||||
"some_index = 5500\n",
|
||||
"plt.subplot(121); plot_digit(X_test_mod[some_index])\n",
|
||||
"plt.subplot(122); plot_digit(y_test_mod[some_index])\n",
|
||||
"save_fig(\"noisy_digit_example\")\n",
|
||||
"save_fig(\"noisy_digit_example_plot\")\n",
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
@@ -1005,7 +1026,7 @@
|
||||
"source": [
|
||||
"clean_digit = knn_clf.predict([X_test_mod[some_index]])\n",
|
||||
"plot_digit(clean_digit)\n",
|
||||
"save_fig(\"cleaned_digit_example\")\n",
|
||||
"save_fig(\"cleaned_digit_example_plot\")\n",
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
@@ -1183,6 +1204,31 @@
|
||||
"source": [
|
||||
"plot_digit(ambiguous_digit)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"source": [
|
||||
"# Exercise solutions"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Coming soon**"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
@@ -1203,10 +1249,14 @@
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.5.1"
|
||||
},
|
||||
"nav_menu": {},
|
||||
"toc": {
|
||||
"navigate_menu": true,
|
||||
"number_sections": true,
|
||||
"sideBar": true,
|
||||
"threshold": 6,
|
||||
"toc_cell": false,
|
||||
"toc_number_sections": true,
|
||||
"toc_threshold": 6,
|
||||
"toc_section_display": "block",
|
||||
"toc_window_display": false
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user