Skip to content

Commit

Permalink
Improve alignment between notebook and book section headers
Browse files Browse the repository at this point in the history
  • Loading branch information
ageron committed Oct 3, 2021
1 parent 4bf39cc commit 62bd4ec
Show file tree
Hide file tree
Showing 6 changed files with 667 additions and 258 deletions.
2 changes: 1 addition & 1 deletion 01_the_machine_learning_landscape.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The code in the book expects the data files to be located in the current directory. I just tweaked it here to fetch the files in datasets/lifesat."
"The code in the book expects the data files to be located in the current directory. I just tweaked it here to fetch the files in `datasets/lifesat`."
]
},
{
Expand Down
145 changes: 127 additions & 18 deletions 05_support_vector_machines.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,16 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Large margin classification"
"# Linear SVM Classification"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The next few code cells generate the first figures in chapter 5. The first actual code sample comes after:"
"The next few code cells generate the first figures in chapter 5. The first actual code sample comes after.\n",
"\n",
"**Code to generate Figure 5–1. Large margin classification**"
]
},
{
Expand Down Expand Up @@ -206,7 +208,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Sensitivity to feature scales"
"**Code to generate Figure 5–2. Sensitivity to feature scales**"
]
},
{
Expand Down Expand Up @@ -271,7 +273,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Sensitivity to outliers"
"## Soft Margin Classification\n",
"**Code to generate Figure 5–3. Hard margin sensitivity to outliers**"
]
},
{
Expand Down Expand Up @@ -349,14 +352,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Large margin *vs* margin violations"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This is the first code example in chapter 5:"
"**This is the first code example in chapter 5:**"
]
},
{
Expand Down Expand Up @@ -419,7 +415,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now let's generate the graph comparing different regularization settings:"
"**Code to generate Figure 5–4. Large margin versus fewer margin violations**"
]
},
{
Expand Down Expand Up @@ -543,7 +539,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Non-linear classification"
"# Nonlinear SVM Classification"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Code to generate Figure 5–5. Adding features to make a dataset linearly separable**"
]
},
{
Expand Down Expand Up @@ -639,6 +642,13 @@
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Here is second code example in the chapter:**"
]
},
{
"cell_type": "code",
"execution_count": 13,
Expand Down Expand Up @@ -679,6 +689,13 @@
"polynomial_svm_clf.fit(X, y)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Code to generate Figure 5–6. Linear SVM classifier using polynomial features**"
]
},
{
"cell_type": "code",
"execution_count": 14,
Expand Down Expand Up @@ -722,6 +739,20 @@
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Polynomial Kernel"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Next code example:**"
]
},
{
"cell_type": "code",
"execution_count": 15,
Expand Down Expand Up @@ -749,6 +780,13 @@
"poly_kernel_svm_clf.fit(X, y)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Code to generate Figure 5–7. SVM classifiers with a polynomial kernel**"
]
},
{
"cell_type": "code",
"execution_count": 16,
Expand Down Expand Up @@ -817,6 +855,20 @@
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Similarity Features"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Code to generate Figure 5–8. Similarity features using the Gaussian RBF**"
]
},
{
"cell_type": "code",
"execution_count": 18,
Expand Down Expand Up @@ -926,6 +978,20 @@
" print(\"Phi({}, {}) = {}\".format(x1_example, landmark, k))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Gaussian RBF Kernel"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Next code example:**"
]
},
{
"cell_type": "code",
"execution_count": 20,
Expand All @@ -951,6 +1017,13 @@
"rbf_kernel_svm_clf.fit(X, y)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Code to generate Figure 5–9. SVM classifiers using an RBF kernel**"
]
},
{
"cell_type": "code",
"execution_count": 21,
Expand Down Expand Up @@ -1015,7 +1088,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Regression\n"
"# SVM Regression"
]
},
{
Expand All @@ -1030,6 +1103,13 @@
"y = (4 + 3 * X + np.random.randn(m, 1)).ravel()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Next code example:**"
]
},
{
"cell_type": "code",
"execution_count": 23,
Expand All @@ -1053,6 +1133,13 @@
"svm_reg.fit(X, y)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Code to generate Figure 5–10. SVM Regression**"
]
},
{
"cell_type": "code",
"execution_count": 24,
Expand Down Expand Up @@ -1152,6 +1239,13 @@
"**Note**: to be future-proof, we set `gamma=\"scale\"`, as this will be the default value in Scikit-Learn 0.22."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Next code example:**"
]
},
{
"cell_type": "code",
"execution_count": 27,
Expand All @@ -1175,6 +1269,13 @@
"svm_poly_reg.fit(X, y)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Code to generate Figure 5–11. SVM Regression using a second-degree polynomial kernel**"
]
},
{
"cell_type": "code",
"execution_count": 28,
Expand Down Expand Up @@ -1242,7 +1343,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Under the hood"
"# Under the Hood\n",
"## Decision Function and Predictions"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Code to generate Figure 5–12. Decision function for the iris dataset**"
]
},
{
Expand Down Expand Up @@ -1324,7 +1433,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Small weight vector results in a large margin"
"**Code to generate Figure 5–13. A smaller weight vector results in a larger margin**"
]
},
{
Expand Down Expand Up @@ -1414,7 +1523,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Hinge loss"
"**Code to generate the Hinge Loss figure:**"
]
},
{
Expand Down
Loading

0 comments on commit 62bd4ec

Please sign in to comment.