diff --git a/doc/pub/DecisionTrees/html/._DecisionTrees-bs000.html b/doc/pub/DecisionTrees/html/._DecisionTrees-bs000.html index f26bb4feb..1c0439170 100644 --- a/doc/pub/DecisionTrees/html/._DecisionTrees-bs000.html +++ b/doc/pub/DecisionTrees/html/._DecisionTrees-bs000.html @@ -56,21 +56,22 @@ Automatically generated HTML file from DocOnce source ('A schematic procedure', 2, None, '___sec10'), ('A classification tree', 2, None, '___sec11'), ('Growing a classification tree', 2, None, '___sec12'), - ('Back to moons again', 2, None, '___sec13'), - ('Playing around with regions', 2, None, '___sec14'), - ('Regression trees', 2, None, '___sec15'), - ('Final regressor code', 2, None, '___sec16'), - ('Classification again: The zoo data', 2, None, '___sec17'), - ('Pros and cons of trees, pros', 2, None, '___sec18'), - ('Disadvantages', 2, None, '___sec19'), - ('Bagging', 2, None, '___sec20'), - ('Simple example, head or tail', 2, None, '___sec21'), - ('Random forests', 2, None, '___sec22'), - ('A simple scikit-learn example', 2, None, '___sec23'), - ('Please, not the moons again!', 2, None, '___sec24'), - ('Bagging examples', 2, None, '___sec25'), - ('Then random forests', 2, None, '___sec26'), - ('Boosting and more', 2, None, '___sec27')]} + ('Classification tree, how to split nodes', 2, None, '___sec13'), + ('Back to moons again', 2, None, '___sec14'), + ('Playing around with regions', 2, None, '___sec15'), + ('Regression trees', 2, None, '___sec16'), + ('Final regressor code', 2, None, '___sec17'), + ('Classification again: The zoo data', 2, None, '___sec18'), + ('Pros and cons of trees, pros', 2, None, '___sec19'), + ('Disadvantages', 2, None, '___sec20'), + ('Bagging', 2, None, '___sec21'), + ('Simple example, head or tail', 2, None, '___sec22'), + ('Random forests', 2, None, '___sec23'), + ('A simple scikit-learn example', 2, None, '___sec24'), + ('Please, not the moons again!', 2, None, '___sec25'), + ('Bagging examples', 2, None, '___sec26'), + ('Then random forests', 2, None, '___sec27'), + ('Boosting and more', 2, None, '___sec28')]} end of tocinfo -->
@@ -121,21 +122,22 @@ MathJax.Hub.Config({-
@@ -194,7 +196,7 @@ MathJax.Hub.Config({
+
from __future__ import division, print_function, unicode_literals
-
-# Common imports
-import numpy as np
-import os
-
-# to make this notebook's output stable across runs
-np.random.seed(42)
-
-# To plot pretty figures
-import matplotlib
-import matplotlib.pyplot as plt
-from matplotlib.colors import ListedColormap
-plt.rcParams['axes.labelsize'] = 14
-plt.rcParams['xtick.labelsize'] = 12
-plt.rcParams['ytick.labelsize'] = 12
-
-
-from sklearn.svm import SVC
-from sklearn import datasets
-from sklearn.tree import DecisionTreeClassifier
-from sklearn.datasets import make_moons
-from sklearn.tree import export_graphviz
-
-Xm, ym = make_moons(n_samples=100, noise=0.25, random_state=53)
-
-deep_tree_clf1 = DecisionTreeClassifier(random_state=42)
-deep_tree_clf2 = DecisionTreeClassifier(min_samples_leaf=4, random_state=42)
-deep_tree_clf1.fit(Xm, ym)
-deep_tree_clf2.fit(Xm, ym)
-
-
-def plot_decision_boundary(clf, X, y, axes=[0, 7.5, 0, 3], iris=True, legend=False, plot_training=True):
- x1s = np.linspace(axes[0], axes[1], 100)
- x2s = np.linspace(axes[2], axes[3], 100)
- x1, x2 = np.meshgrid(x1s, x2s)
- X_new = np.c_[x1.ravel(), x2.ravel()]
- y_pred = clf.predict(X_new).reshape(x1.shape)
- custom_cmap = ListedColormap(['#fafab0','#9898ff','#a0faa0'])
- plt.contourf(x1, x2, y_pred, alpha=0.3, cmap=custom_cmap)
- if not iris:
- custom_cmap2 = ListedColormap(['#7d7d58','#4c4c7f','#507d50'])
- plt.contour(x1, x2, y_pred, cmap=custom_cmap2, alpha=0.8)
- if plot_training:
- plt.plot(X[:, 0][y==0], X[:, 1][y==0], "yo", label="Iris-Setosa")
- plt.plot(X[:, 0][y==1], X[:, 1][y==1], "bs", label="Iris-Versicolor")
- plt.plot(X[:, 0][y==2], X[:, 1][y==2], "g^", label="Iris-Virginica")
- plt.axis(axes)
- if iris:
- plt.xlabel("Petal length", fontsize=14)
- plt.ylabel("Petal width", fontsize=14)
- else:
- plt.xlabel(r"$x_1$", fontsize=18)
- plt.ylabel(r"$x_2$", fontsize=18, rotation=0)
- if legend:
- plt.legend(loc="lower right", fontsize=14)
-plt.figure(figsize=(11, 4))
-plt.subplot(121)
-plot_decision_boundary(deep_tree_clf1, Xm, ym, axes=[-1.5, 2.5, -1, 1.5], iris=False)
-plt.title("No restrictions", fontsize=16)
-plt.subplot(122)
-plot_decision_boundary(deep_tree_clf2, Xm, ym, axes=[-1.5, 2.5, -1, 1.5], iris=False)
-plt.title("min_samples_leaf = {}".format(deep_tree_clf2.min_samples_leaf), fontsize=14)
-plt.show()
-
@@ -246,7 +183,7 @@ plt.show()
-
np.random.seed(6)
-Xs = np.random.rand(100, 2) - 0.5
-ys = (Xs[:, 0] > 0).astype(np.float32) * 2
+from __future__ import division, print_function, unicode_literals
-angle = np.pi / 4
-rotation_matrix = np.array([[np.cos(angle), -np.sin(angle)], [np.sin(angle), np.cos(angle)]])
-Xsr = Xs.dot(rotation_matrix)
+# Common imports
+import numpy as np
+import os
-tree_clf_s = DecisionTreeClassifier(random_state=42)
-tree_clf_s.fit(Xs, ys)
-tree_clf_sr = DecisionTreeClassifier(random_state=42)
-tree_clf_sr.fit(Xsr, ys)
+# to make this notebook's output stable across runs
+np.random.seed(42)
+# To plot pretty figures
+import matplotlib
+import matplotlib.pyplot as plt
+from matplotlib.colors import ListedColormap
+plt.rcParams['axes.labelsize'] = 14
+plt.rcParams['xtick.labelsize'] = 12
+plt.rcParams['ytick.labelsize'] = 12
+
+
+from sklearn.svm import SVC
+from sklearn import datasets
+from sklearn.tree import DecisionTreeClassifier
+from sklearn.datasets import make_moons
+from sklearn.tree import export_graphviz
+
+Xm, ym = make_moons(n_samples=100, noise=0.25, random_state=53)
+
+deep_tree_clf1 = DecisionTreeClassifier(random_state=42)
+deep_tree_clf2 = DecisionTreeClassifier(min_samples_leaf=4, random_state=42)
+deep_tree_clf1.fit(Xm, ym)
+deep_tree_clf2.fit(Xm, ym)
+
+
+def plot_decision_boundary(clf, X, y, axes=[0, 7.5, 0, 3], iris=True, legend=False, plot_training=True):
+ x1s = np.linspace(axes[0], axes[1], 100)
+ x2s = np.linspace(axes[2], axes[3], 100)
+ x1, x2 = np.meshgrid(x1s, x2s)
+ X_new = np.c_[x1.ravel(), x2.ravel()]
+ y_pred = clf.predict(X_new).reshape(x1.shape)
+ custom_cmap = ListedColormap(['#fafab0','#9898ff','#a0faa0'])
+ plt.contourf(x1, x2, y_pred, alpha=0.3, cmap=custom_cmap)
+ if not iris:
+ custom_cmap2 = ListedColormap(['#7d7d58','#4c4c7f','#507d50'])
+ plt.contour(x1, x2, y_pred, cmap=custom_cmap2, alpha=0.8)
+ if plot_training:
+ plt.plot(X[:, 0][y==0], X[:, 1][y==0], "yo", label="Iris-Setosa")
+ plt.plot(X[:, 0][y==1], X[:, 1][y==1], "bs", label="Iris-Versicolor")
+ plt.plot(X[:, 0][y==2], X[:, 1][y==2], "g^", label="Iris-Virginica")
+ plt.axis(axes)
+ if iris:
+ plt.xlabel("Petal length", fontsize=14)
+ plt.ylabel("Petal width", fontsize=14)
+ else:
+ plt.xlabel(r"$x_1$", fontsize=18)
+ plt.ylabel(r"$x_2$", fontsize=18, rotation=0)
+ if legend:
+ plt.legend(loc="lower right", fontsize=14)
plt.figure(figsize=(11, 4))
plt.subplot(121)
-plot_decision_boundary(tree_clf_s, Xs, ys, axes=[-0.7, 0.7, -0.7, 0.7], iris=False)
+plot_decision_boundary(deep_tree_clf1, Xm, ym, axes=[-1.5, 2.5, -1, 1.5], iris=False)
+plt.title("No restrictions", fontsize=16)
plt.subplot(122)
-plot_decision_boundary(tree_clf_sr, Xsr, ys, axes=[-0.7, 0.7, -0.7, 0.7], iris=False)
-
+plot_decision_boundary(deep_tree_clf2, Xm, ym, axes=[-1.5, 2.5, -1, 1.5], iris=False)
+plt.title("min_samples_leaf = {}".format(deep_tree_clf2.min_samples_leaf), fontsize=14)
plt.show()
@@ -202,7 +248,7 @@ plt.show()
-
# Quadratic training set + noise
-np.random.seed(42)
-m = 200
-X = np.random.rand(m, 1)
-y = 4 * (X - 0.5) ** 2
-y = y + np.random.randn(m, 1) / 10
-+
np.random.seed(6)
+Xs = np.random.rand(100, 2) - 0.5
+ys = (Xs[:, 0] > 0).astype(np.float32) * 2
-
-from sklearn.tree import DecisionTreeRegressor
+angle = np.pi / 4
+rotation_matrix = np.array([[np.cos(angle), -np.sin(angle)], [np.sin(angle), np.cos(angle)]])
+Xsr = Xs.dot(rotation_matrix)
-tree_reg = DecisionTreeRegressor(max_depth=2, random_state=42)
-tree_reg.fit(X, y)
+tree_clf_s = DecisionTreeClassifier(random_state=42)
+tree_clf_s.fit(Xs, ys)
+tree_clf_sr = DecisionTreeClassifier(random_state=42)
+tree_clf_sr.fit(Xsr, ys)
+
+plt.figure(figsize=(11, 4))
+plt.subplot(121)
+plot_decision_boundary(tree_clf_s, Xs, ys, axes=[-0.7, 0.7, -0.7, 0.7], iris=False)
+plt.subplot(122)
+plot_decision_boundary(tree_clf_sr, Xsr, ys, axes=[-0.7, 0.7, -0.7, 0.7], iris=False)
+
+plt.show()
@@ -196,7 +204,7 @@ tree_reg.fit(X, y)
+ + +
# Quadratic training set + noise
+np.random.seed(42)
+m = 200
+X = np.random.rand(m, 1)
+y = 4 * (X - 0.5) ** 2
+y = y + np.random.randn(m, 1) / 10
+
from sklearn.tree import DecisionTreeRegressor
-tree_reg1 = DecisionTreeRegressor(random_state=42, max_depth=2)
-tree_reg2 = DecisionTreeRegressor(random_state=42, max_depth=3)
-tree_reg1.fit(X, y)
-tree_reg2.fit(X, y)
-
-def plot_regression_predictions(tree_reg, X, y, axes=[0, 1, -0.2, 1], ylabel="$y$"):
- x1 = np.linspace(axes[0], axes[1], 500).reshape(-1, 1)
- y_pred = tree_reg.predict(x1)
- plt.axis(axes)
- plt.xlabel("$x_1$", fontsize=18)
- if ylabel:
- plt.ylabel(ylabel, fontsize=18, rotation=0)
- plt.plot(X, y, "b.")
- plt.plot(x1, y_pred, "r.-", linewidth=2, label=r"$\hat{y}$")
-
-plt.figure(figsize=(11, 4))
-plt.subplot(121)
-plot_regression_predictions(tree_reg1, X, y)
-for split, style in ((0.1973, "k-"), (0.0917, "k--"), (0.7718, "k--")):
- plt.plot([split, split], [-0.2, 1], style, linewidth=2)
-plt.text(0.21, 0.65, "Depth=0", fontsize=15)
-plt.text(0.01, 0.2, "Depth=1", fontsize=13)
-plt.text(0.65, 0.8, "Depth=1", fontsize=13)
-plt.legend(loc="upper center", fontsize=18)
-plt.title("max_depth=2", fontsize=14)
-
-plt.subplot(122)
-plot_regression_predictions(tree_reg2, X, y, ylabel=None)
-for split, style in ((0.1973, "k-"), (0.0917, "k--"), (0.7718, "k--")):
- plt.plot([split, split], [-0.2, 1], style, linewidth=2)
-for split in (0.0458, 0.1298, 0.2873, 0.9040):
- plt.plot([split, split], [-0.2, 1], "k:", linewidth=1)
-plt.text(0.3, 0.5, "Depth=2", fontsize=13)
-plt.title("max_depth=3", fontsize=14)
-
-plt.show()
-- - -
tree_reg1 = DecisionTreeRegressor(random_state=42)
-tree_reg2 = DecisionTreeRegressor(random_state=42, min_samples_leaf=10)
-tree_reg1.fit(X, y)
-tree_reg2.fit(X, y)
-
-x1 = np.linspace(0, 1, 500).reshape(-1, 1)
-y_pred1 = tree_reg1.predict(x1)
-y_pred2 = tree_reg2.predict(x1)
-
-plt.figure(figsize=(11, 4))
-
-plt.subplot(121)
-plt.plot(X, y, "b.")
-plt.plot(x1, y_pred1, "r.-", linewidth=2, label=r"$\hat{y}$")
-plt.axis([0, 1, -0.2, 1.1])
-plt.xlabel("$x_1$", fontsize=18)
-plt.ylabel("$y$", fontsize=18, rotation=0)
-plt.legend(loc="upper center", fontsize=18)
-plt.title("No restrictions", fontsize=14)
-
-plt.subplot(122)
-plt.plot(X, y, "b.")
-plt.plot(x1, y_pred2, "r.-", linewidth=2, label=r"$\hat{y}$")
-plt.axis([0, 1, -0.2, 1.1])
-plt.xlabel("$x_1$", fontsize=18)
-plt.title("min_samples_leaf={}".format(tree_reg2.min_samples_leaf), fontsize=14)
-
-plt.show()
+tree_reg = DecisionTreeRegressor(max_depth=2, random_state=42)
+tree_reg.fit(X, y)
@@ -252,7 +198,7 @@ plt.show()
-
import pandas as pd
-import numpy as np
-from pprint import pprint
-from sklearn.tree import DecisionTreeClassifier
+from sklearn.tree import DecisionTreeRegressor
-#Import the dataset
-dataset = pd.read_csv('data/zoo.csv')
-#We drop the animal names since this is not a good feature to split the data on
-#dataset=dataset.drop('animal_name',axis=1)
-#Split the data into a training and a testing set
-train_features = dataset.iloc[:80,:-1]
-test_features = dataset.iloc[80:,:-1]
-train_targets = dataset.iloc[:80,-1]
-test_targets = dataset.iloc[80:,-1]
-#Train the model
-tree = DecisionTreeClassifier(criterion = 'entropy').fit(train_features,train_targets)
-#Predict the classes of new, unseen data
-prediction = tree.predict(test_features)
-#Check the accuracy
-print("The prediction accuracy is: ",tree.score(test_features,test_targets)*100,"%")
+tree_reg1 = DecisionTreeRegressor(random_state=42, max_depth=2)
+tree_reg2 = DecisionTreeRegressor(random_state=42, max_depth=3)
+tree_reg1.fit(X, y)
+tree_reg2.fit(X, y)
+
+def plot_regression_predictions(tree_reg, X, y, axes=[0, 1, -0.2, 1], ylabel="$y$"):
+ x1 = np.linspace(axes[0], axes[1], 500).reshape(-1, 1)
+ y_pred = tree_reg.predict(x1)
+ plt.axis(axes)
+ plt.xlabel("$x_1$", fontsize=18)
+ if ylabel:
+ plt.ylabel(ylabel, fontsize=18, rotation=0)
+ plt.plot(X, y, "b.")
+ plt.plot(x1, y_pred, "r.-", linewidth=2, label=r"$\hat{y}$")
+
+plt.figure(figsize=(11, 4))
+plt.subplot(121)
+plot_regression_predictions(tree_reg1, X, y)
+for split, style in ((0.1973, "k-"), (0.0917, "k--"), (0.7718, "k--")):
+ plt.plot([split, split], [-0.2, 1], style, linewidth=2)
+plt.text(0.21, 0.65, "Depth=0", fontsize=15)
+plt.text(0.01, 0.2, "Depth=1", fontsize=13)
+plt.text(0.65, 0.8, "Depth=1", fontsize=13)
+plt.legend(loc="upper center", fontsize=18)
+plt.title("max_depth=2", fontsize=14)
+
+plt.subplot(122)
+plot_regression_predictions(tree_reg2, X, y, ylabel=None)
+for split, style in ((0.1973, "k-"), (0.0917, "k--"), (0.7718, "k--")):
+ plt.plot([split, split], [-0.2, 1], style, linewidth=2)
+for split in (0.0458, 0.1298, 0.2873, 0.9040):
+ plt.plot([split, split], [-0.2, 1], "k:", linewidth=1)
+plt.text(0.3, 0.5, "Depth=2", fontsize=13)
+plt.title("max_depth=3", fontsize=14)
+
+plt.show()
+
+
+
+
+
tree_reg1 = DecisionTreeRegressor(random_state=42)
+tree_reg2 = DecisionTreeRegressor(random_state=42, min_samples_leaf=10)
+tree_reg1.fit(X, y)
+tree_reg2.fit(X, y)
+
+x1 = np.linspace(0, 1, 500).reshape(-1, 1)
+y_pred1 = tree_reg1.predict(x1)
+y_pred2 = tree_reg2.predict(x1)
+
+plt.figure(figsize=(11, 4))
+
+plt.subplot(121)
+plt.plot(X, y, "b.")
+plt.plot(x1, y_pred1, "r.-", linewidth=2, label=r"$\hat{y}$")
+plt.axis([0, 1, -0.2, 1.1])
+plt.xlabel("$x_1$", fontsize=18)
+plt.ylabel("$y$", fontsize=18, rotation=0)
+plt.legend(loc="upper center", fontsize=18)
+plt.title("No restrictions", fontsize=14)
+
+plt.subplot(122)
+plt.plot(X, y, "b.")
+plt.plot(x1, y_pred2, "r.-", linewidth=2, label=r"$\hat{y}$")
+plt.axis([0, 1, -0.2, 1.1])
+plt.xlabel("$x_1$", fontsize=18)
+plt.title("min_samples_leaf={}".format(tree_reg2.min_samples_leaf), fontsize=14)
+
+plt.show()
@@ -202,7 +254,7 @@ prediction = tree27
28
...
- 29
+ 30
»
diff --git a/doc/pub/DecisionTrees/html/._DecisionTrees-bs019.html b/doc/pub/DecisionTrees/html/._DecisionTrees-bs019.html
index 34d93e91f..72ef26466 100644
--- a/doc/pub/DecisionTrees/html/._DecisionTrees-bs019.html
+++ b/doc/pub/DecisionTrees/html/._DecisionTrees-bs019.html
@@ -56,21 +56,22 @@ Automatically generated HTML file from DocOnce source
('A schematic procedure', 2, None, '___sec10'),
('A classification tree', 2, None, '___sec11'),
('Growing a classification tree', 2, None, '___sec12'),
- ('Back to moons again', 2, None, '___sec13'),
- ('Playing around with regions', 2, None, '___sec14'),
- ('Regression trees', 2, None, '___sec15'),
- ('Final regressor code', 2, None, '___sec16'),
- ('Classification again: The zoo data', 2, None, '___sec17'),
- ('Pros and cons of trees, pros', 2, None, '___sec18'),
- ('Disadvantages', 2, None, '___sec19'),
- ('Bagging', 2, None, '___sec20'),
- ('Simple example, head or tail', 2, None, '___sec21'),
- ('Random forests', 2, None, '___sec22'),
- ('A simple scikit-learn example', 2, None, '___sec23'),
- ('Please, not the moons again!', 2, None, '___sec24'),
- ('Bagging examples', 2, None, '___sec25'),
- ('Then random forests', 2, None, '___sec26'),
- ('Boosting and more', 2, None, '___sec27')]}
+ ('Classification tree, how to split nodes', 2, None, '___sec13'),
+ ('Back to moons again', 2, None, '___sec14'),
+ ('Playing around with regions', 2, None, '___sec15'),
+ ('Regression trees', 2, None, '___sec16'),
+ ('Final regressor code', 2, None, '___sec17'),
+ ('Classification again: The zoo data', 2, None, '___sec18'),
+ ('Pros and cons of trees, pros', 2, None, '___sec19'),
+ ('Disadvantages', 2, None, '___sec20'),
+ ('Bagging', 2, None, '___sec21'),
+ ('Simple example, head or tail', 2, None, '___sec22'),
+ ('Random forests', 2, None, '___sec23'),
+ ('A simple scikit-learn example', 2, None, '___sec24'),
+ ('Please, not the moons again!', 2, None, '___sec25'),
+ ('Bagging examples', 2, None, '___sec26'),
+ ('Then random forests', 2, None, '___sec27'),
+ ('Boosting and more', 2, None, '___sec28')]}
end of tocinfo -->
@@ -121,21 +122,22 @@ MathJax.Hub.Config({
A schematic procedure
A classification tree
Growing a classification tree
- Back to moons again
- Playing around with regions
- Regression trees
- Final regressor code
- Classification again: The zoo data
- Pros and cons of trees, pros
- Disadvantages
- Bagging
- Simple example, head or tail
- Random forests
- A simple scikit-learn example
- Please, not the moons again!
- Bagging examples
- Then random forests
- Boosting and more
+ Classification tree, how to split nodes
+ Back to moons again
+ Playing around with regions
+ Regression trees
+ Final regressor code
+ Classification again: The zoo data
+ Pros and cons of trees, pros
+ Disadvantages
+ Bagging
+ Simple example, head or tail
+ Random forests
+ A simple scikit-learn example
+ Please, not the moons again!
+ Bagging examples
+ Then random forests
+ Boosting and more
@@ -151,18 +153,32 @@ MathJax.Hub.Config({
-Pros and cons of trees, pros
+Classification again: The zoo data
+
-
-- White box, easy to interpret model. Some people believe that decision trees more closely mirror human decision-making than do the regression and classification approaches discussed earlier (think of support vector machines)
-- Trees are very easy to explain to people. In fact, they are even easier to explain than linear regression!
-- No feature normalization needed
-- Tree models can handle both continuous and categorical data (Classification and Regression Trees)
-- Can model nonlinear relationships
-- Can model interactions between the different descriptive features
-- Trees can be displayed graphically, and are easily interpreted even by a non-expert (especially if they are small)
-
+
+import pandas as pd
+import numpy as np
+from pprint import pprint
+from sklearn.tree import DecisionTreeClassifier
+#Import the dataset
+dataset = pd.read_csv('data/zoo.csv')
+#We drop the animal names since this is not a good feature to split the data on
+#dataset=dataset.drop('animal_name',axis=1)
+#Split the data into a training and a testing set
+train_features = dataset.iloc[:80,:-1]
+test_features = dataset.iloc[80:,:-1]
+train_targets = dataset.iloc[:80,-1]
+test_targets = dataset.iloc[80:,-1]
+#Train the model
+tree = DecisionTreeClassifier(criterion = 'entropy').fit(train_features,train_targets)
+#Predict the classes of new, unseen data
+prediction = tree.predict(test_features)
+#Check the accuracy
+print("The prediction accuracy is: ",tree.score(test_features,test_targets)*100,"%")
+
+
diff --git a/doc/pub/DecisionTrees/html/._DecisionTrees-bs020.html b/doc/pub/DecisionTrees/html/._DecisionTrees-bs020.html
index da19fc24a..acb681e9b 100644
--- a/doc/pub/DecisionTrees/html/._DecisionTrees-bs020.html
+++ b/doc/pub/DecisionTrees/html/._DecisionTrees-bs020.html
@@ -56,21 +56,22 @@ Automatically generated HTML file from DocOnce source
('A schematic procedure', 2, None, '___sec10'),
('A classification tree', 2, None, '___sec11'),
('Growing a classification tree', 2, None, '___sec12'),
- ('Back to moons again', 2, None, '___sec13'),
- ('Playing around with regions', 2, None, '___sec14'),
- ('Regression trees', 2, None, '___sec15'),
- ('Final regressor code', 2, None, '___sec16'),
- ('Classification again: The zoo data', 2, None, '___sec17'),
- ('Pros and cons of trees, pros', 2, None, '___sec18'),
- ('Disadvantages', 2, None, '___sec19'),
- ('Bagging', 2, None, '___sec20'),
- ('Simple example, head or tail', 2, None, '___sec21'),
- ('Random forests', 2, None, '___sec22'),
- ('A simple scikit-learn example', 2, None, '___sec23'),
- ('Please, not the moons again!', 2, None, '___sec24'),
- ('Bagging examples', 2, None, '___sec25'),
- ('Then random forests', 2, None, '___sec26'),
- ('Boosting and more', 2, None, '___sec27')]}
+ ('Classification tree, how to split nodes', 2, None, '___sec13'),
+ ('Back to moons again', 2, None, '___sec14'),
+ ('Playing around with regions', 2, None, '___sec15'),
+ ('Regression trees', 2, None, '___sec16'),
+ ('Final regressor code', 2, None, '___sec17'),
+ ('Classification again: The zoo data', 2, None, '___sec18'),
+ ('Pros and cons of trees, pros', 2, None, '___sec19'),
+ ('Disadvantages', 2, None, '___sec20'),
+ ('Bagging', 2, None, '___sec21'),
+ ('Simple example, head or tail', 2, None, '___sec22'),
+ ('Random forests', 2, None, '___sec23'),
+ ('A simple scikit-learn example', 2, None, '___sec24'),
+ ('Please, not the moons again!', 2, None, '___sec25'),
+ ('Bagging examples', 2, None, '___sec26'),
+ ('Then random forests', 2, None, '___sec27'),
+ ('Boosting and more', 2, None, '___sec28')]}
end of tocinfo -->
@@ -121,21 +122,22 @@ MathJax.Hub.Config({
A schematic procedure
A classification tree
Growing a classification tree
- Back to moons again
- Playing around with regions
- Regression trees
- Final regressor code
- Classification again: The zoo data
- Pros and cons of trees, pros
- Disadvantages
- Bagging
- Simple example, head or tail
- Random forests
- A simple scikit-learn example
- Please, not the moons again!
- Bagging examples
- Then random forests
- Boosting and more
+ Classification tree, how to split nodes
+ Back to moons again
+ Playing around with regions
+ Regression trees
+ Final regressor code
+ Classification again: The zoo data
+ Pros and cons of trees, pros
+ Disadvantages
+ Bagging
+ Simple example, head or tail
+ Random forests
+ A simple scikit-learn example
+ Please, not the moons again!
+ Bagging examples
+ Then random forests
+ Boosting and more
@@ -151,21 +153,18 @@ MathJax.Hub.Config({
-Disadvantages
+Pros and cons of trees, pros
-- Unfortunately, trees generally do not have the same level of predictive accuracy as some of the other regression and classification approaches
-- If continuous features are used the tree may become quite large and hence less interpretable
-- Decision trees are prone to overfit the training data and hence do not well generalize the data if no stopping criteria or improvements like pruning, boosting or bagging are implemented
-- Small changes in the data may lead to a completely different tree. This issue can be addressed by using ensemble methods like bagging, boosting or random forests
-- Unbalanced datasets where some target feature values occur much more frequently than others may lead to biased trees since the frequently occurring feature values are preferred over the less frequently occurring ones.
-- If the number of features is relatively large (high dimensional) and the number of instances is relatively low, the tree might overfit the data
-- Features with many levels may be preferred over features with less levels since for them it is more easy to split the dataset such that the sub datasets only contain pure target feature values. This issue can be addressed by preferring for instance the information gain ratio as splitting criteria over information gain
+- White box, easy to interpret model. Some people believe that decision trees more closely mirror human decision-making than do the regression and classification approaches discussed earlier (think of support vector machines)
+- Trees are very easy to explain to people. In fact, they are even easier to explain than linear regression!
+- No feature normalization needed
+- Tree models can handle both continuous and categorical data (Classification and Regression Trees)
+- Can model nonlinear relationships
+- Can model interactions between the different descriptive features
+- Trees can be displayed graphically, and are easily interpreted even by a non-expert (especially if they are small)
-However, by aggregating many decision trees, using methods like bagging, random forests, and boosting, the predictive performance of trees can be substantially improved.
-
-
@@ -189,6 +188,7 @@ However, by aggregating many decision trees, using methods like bagging, random
- 27
- 28
- 29
+ - 30
- »
diff --git a/doc/pub/DecisionTrees/html/._DecisionTrees-bs021.html b/doc/pub/DecisionTrees/html/._DecisionTrees-bs021.html
index e8830c419..7a7da7bfd 100644
--- a/doc/pub/DecisionTrees/html/._DecisionTrees-bs021.html
+++ b/doc/pub/DecisionTrees/html/._DecisionTrees-bs021.html
@@ -56,21 +56,22 @@ Automatically generated HTML file from DocOnce source
('A schematic procedure', 2, None, '___sec10'),
('A classification tree', 2, None, '___sec11'),
('Growing a classification tree', 2, None, '___sec12'),
- ('Back to moons again', 2, None, '___sec13'),
- ('Playing around with regions', 2, None, '___sec14'),
- ('Regression trees', 2, None, '___sec15'),
- ('Final regressor code', 2, None, '___sec16'),
- ('Classification again: The zoo data', 2, None, '___sec17'),
- ('Pros and cons of trees, pros', 2, None, '___sec18'),
- ('Disadvantages', 2, None, '___sec19'),
- ('Bagging', 2, None, '___sec20'),
- ('Simple example, head or tail', 2, None, '___sec21'),
- ('Random forests', 2, None, '___sec22'),
- ('A simple scikit-learn example', 2, None, '___sec23'),
- ('Please, not the moons again!', 2, None, '___sec24'),
- ('Bagging examples', 2, None, '___sec25'),
- ('Then random forests', 2, None, '___sec26'),
- ('Boosting and more', 2, None, '___sec27')]}
+ ('Classification tree, how to split nodes', 2, None, '___sec13'),
+ ('Back to moons again', 2, None, '___sec14'),
+ ('Playing around with regions', 2, None, '___sec15'),
+ ('Regression trees', 2, None, '___sec16'),
+ ('Final regressor code', 2, None, '___sec17'),
+ ('Classification again: The zoo data', 2, None, '___sec18'),
+ ('Pros and cons of trees, pros', 2, None, '___sec19'),
+ ('Disadvantages', 2, None, '___sec20'),
+ ('Bagging', 2, None, '___sec21'),
+ ('Simple example, head or tail', 2, None, '___sec22'),
+ ('Random forests', 2, None, '___sec23'),
+ ('A simple scikit-learn example', 2, None, '___sec24'),
+ ('Please, not the moons again!', 2, None, '___sec25'),
+ ('Bagging examples', 2, None, '___sec26'),
+ ('Then random forests', 2, None, '___sec27'),
+ ('Boosting and more', 2, None, '___sec28')]}
end of tocinfo -->
@@ -121,21 +122,22 @@ MathJax.Hub.Config({
A schematic procedure
A classification tree
Growing a classification tree
- Back to moons again
- Playing around with regions
- Regression trees
- Final regressor code
- Classification again: The zoo data
- Pros and cons of trees, pros
- Disadvantages
- Bagging
- Simple example, head or tail
- Random forests
- A simple scikit-learn example
- Please, not the moons again!
- Bagging examples
- Then random forests
- Boosting and more
+ Classification tree, how to split nodes
+ Back to moons again
+ Playing around with regions
+ Regression trees
+ Final regressor code
+ Classification again: The zoo data
+ Pros and cons of trees, pros
+ Disadvantages
+ Bagging
+ Simple example, head or tail
+ Random forests
+ A simple scikit-learn example
+ Please, not the moons again!
+ Bagging examples
+ Then random forests
+ Boosting and more
@@ -151,45 +153,19 @@ MathJax.Hub.Config({
-Bagging
+Disadvantages
-
-The plain decision trees suffer from high
-variance. This means that if we split the training data into two parts
-at random, and fit a decision tree to both halves, the results that we
-get could be quite different. In contrast, a procedure with low
-variance will yield similar results if applied repeatedly to distinct
-data sets; linear regression tends to have low variance, if the ratio
-of \( n \) to \( p \) is moderately large.
+
+- Unfortunately, trees generally do not have the same level of predictive accuracy as some of the other regression and classification approaches
+- If continuous features are used the tree may become quite large and hence less interpretable
+- Decision trees are prone to overfit the training data and hence do not well generalize the data if no stopping criteria or improvements like pruning, boosting or bagging are implemented
+- Small changes in the data may lead to a completely different tree. This issue can be addressed by using ensemble methods like bagging, boosting or random forests
+- Unbalanced datasets where some target feature values occur much more frequently than others may lead to biased trees since the frequently occurring feature values are preferred over the less frequently occurring ones.
+- If the number of features is relatively large (high dimensional) and the number of instances is relatively low, the tree might overfit the data
+- Features with many levels may be preferred over features with less levels since for them it is more easy to split the dataset such that the sub datasets only contain pure target feature values. This issue can be addressed by preferring for instance the information gain ratio as splitting criteria over information gain
+
-
-Bootstrap aggregation, or just bagging, is a
-general-purpose procedure for reducing the variance of a statistical
-learning method.
-
-
-Bagging typically results in improved accuracy
-over prediction using a single tree. Unfortunately, however, it can be
-difficult to interpret the resulting model. Recall that one of the
-advantages of decision trees is the attractive and easily interpreted
-diagram that results.
-
-
-However, when we bag a large number of trees, it is no longer
-possible to represent the resulting statistical learning procedure
-using a single tree, and it is no longer clear which variables are
-most important to the procedure. Thus, bagging improves prediction
-accuracy at the expense of interpretability. Although the collection
-of bagged trees is much more difficult to interpret than a single
-tree, one can obtain an overall summary of the importance of each
-predictor using the MSE (for bagging regression trees) or the Gini
-index (for bagging classification trees). In the case of bagging
-regression trees, we can record the total amount that the MSE is
-decreased due to splits over a given predictor, averaged over all \( B \) possible
-trees. A large value indicates an important predictor. Similarly, in
-the context of bagging classification trees, we can add up the total
-amount that the Gini index is decreased by splits over a given
-predictor, averaged over all \( B \) trees.
+However, by aggregating many decision trees, using methods like bagging, random forests, and boosting, the predictive performance of trees can be substantially improved.
@@ -214,6 +190,7 @@ predictor, averaged over all \( B \) trees.
27
28
29
+ 30
»
diff --git a/doc/pub/DecisionTrees/html/._DecisionTrees-bs022.html b/doc/pub/DecisionTrees/html/._DecisionTrees-bs022.html
index 6b4671aa8..171c2bc2e 100644
--- a/doc/pub/DecisionTrees/html/._DecisionTrees-bs022.html
+++ b/doc/pub/DecisionTrees/html/._DecisionTrees-bs022.html
@@ -56,21 +56,22 @@ Automatically generated HTML file from DocOnce source
('A schematic procedure', 2, None, '___sec10'),
('A classification tree', 2, None, '___sec11'),
('Growing a classification tree', 2, None, '___sec12'),
- ('Back to moons again', 2, None, '___sec13'),
- ('Playing around with regions', 2, None, '___sec14'),
- ('Regression trees', 2, None, '___sec15'),
- ('Final regressor code', 2, None, '___sec16'),
- ('Classification again: The zoo data', 2, None, '___sec17'),
- ('Pros and cons of trees, pros', 2, None, '___sec18'),
- ('Disadvantages', 2, None, '___sec19'),
- ('Bagging', 2, None, '___sec20'),
- ('Simple example, head or tail', 2, None, '___sec21'),
- ('Random forests', 2, None, '___sec22'),
- ('A simple scikit-learn example', 2, None, '___sec23'),
- ('Please, not the moons again!', 2, None, '___sec24'),
- ('Bagging examples', 2, None, '___sec25'),
- ('Then random forests', 2, None, '___sec26'),
- ('Boosting and more', 2, None, '___sec27')]}
+ ('Classification tree, how to split nodes', 2, None, '___sec13'),
+ ('Back to moons again', 2, None, '___sec14'),
+ ('Playing around with regions', 2, None, '___sec15'),
+ ('Regression trees', 2, None, '___sec16'),
+ ('Final regressor code', 2, None, '___sec17'),
+ ('Classification again: The zoo data', 2, None, '___sec18'),
+ ('Pros and cons of trees, pros', 2, None, '___sec19'),
+ ('Disadvantages', 2, None, '___sec20'),
+ ('Bagging', 2, None, '___sec21'),
+ ('Simple example, head or tail', 2, None, '___sec22'),
+ ('Random forests', 2, None, '___sec23'),
+ ('A simple scikit-learn example', 2, None, '___sec24'),
+ ('Please, not the moons again!', 2, None, '___sec25'),
+ ('Bagging examples', 2, None, '___sec26'),
+ ('Then random forests', 2, None, '___sec27'),
+ ('Boosting and more', 2, None, '___sec28')]}
end of tocinfo -->
@@ -121,21 +122,22 @@ MathJax.Hub.Config({
A schematic procedure
A classification tree
Growing a classification tree
- Back to moons again
- Playing around with regions
- Regression trees
- Final regressor code
- Classification again: The zoo data
- Pros and cons of trees, pros
- Disadvantages
- Bagging
- Simple example, head or tail
- Random forests
- A simple scikit-learn example
- Please, not the moons again!
- Bagging examples
- Then random forests
- Boosting and more
+ Classification tree, how to split nodes
+ Back to moons again
+ Playing around with regions
+ Regression trees
+ Final regressor code
+ Classification again: The zoo data
+ Pros and cons of trees, pros
+ Disadvantages
+ Bagging
+ Simple example, head or tail
+ Random forests
+ A simple scikit-learn example
+ Please, not the moons again!
+ Bagging examples
+ Then random forests
+ Boosting and more
@@ -151,23 +153,46 @@ MathJax.Hub.Config({
-Simple example, head or tail
-
+
Bagging
+
+
+The plain decision trees suffer from high
+variance. This means that if we split the training data into two parts
+at random, and fit a decision tree to both halves, the results that we
+get could be quite different. In contrast, a procedure with low
+variance will yield similar results if applied repeatedly to distinct
+data sets; linear regression tends to have low variance, if the ratio
+of \( n \) to \( p \) is moderately large.
+
+
+Bootstrap aggregation, or just bagging, is a
+general-purpose procedure for reducing the variance of a statistical
+learning method.
+
+
+Bagging typically results in improved accuracy
+over prediction using a single tree. Unfortunately, however, it can be
+difficult to interpret the resulting model. Recall that one of the
+advantages of decision trees is the attractive and easily interpreted
+diagram that results.
+
+
+However, when we bag a large number of trees, it is no longer
+possible to represent the resulting statistical learning procedure
+using a single tree, and it is no longer clear which variables are
+most important to the procedure. Thus, bagging improves prediction
+accuracy at the expense of interpretability. Although the collection
+of bagged trees is much more difficult to interpret than a single
+tree, one can obtain an overall summary of the importance of each
+predictor using the MSE (for bagging regression trees) or the Gini
+index (for bagging classification trees). In the case of bagging
+regression trees, we can record the total amount that the MSE is
+decreased due to splits over a given predictor, averaged over all \( B \) possible
+trees. A large value indicates an important predictor. Similarly, in
+the context of bagging classification trees, we can add up the total
+amount that the Gini index is decreased by splits over a given
+predictor, averaged over all \( B \) trees.
-
-
heads_proba = 0.51
-coin_tosses = (np.random.rand(10000, 10) < heads_proba).astype(np.int32)
-cumulative_heads_ratio = np.cumsum(coin_tosses, axis=0) / np.arange(1, 10001).reshape(-1, 1)
-plt.figure(figsize=(8,3.5))
-plt.plot(cumulative_heads_ratio)
-plt.plot([0, 10000], [0.51, 0.51], "k--", linewidth=2, label="51%")
-plt.plot([0, 10000], [0.5, 0.5], "k-", label="50%")
-plt.xlabel("Number of coin tosses")
-plt.ylabel("Heads ratio")
-plt.legend(loc="lower right")
-plt.axis([0, 10000, 0.42, 0.58])
-plt.show()
-
@@ -190,6 +215,7 @@ plt.show()
27
28
29
+ 30
»
diff --git a/doc/pub/DecisionTrees/html/._DecisionTrees-bs023.html b/doc/pub/DecisionTrees/html/._DecisionTrees-bs023.html
index 86309fd55..1507561b9 100644
--- a/doc/pub/DecisionTrees/html/._DecisionTrees-bs023.html
+++ b/doc/pub/DecisionTrees/html/._DecisionTrees-bs023.html
@@ -56,21 +56,22 @@ Automatically generated HTML file from DocOnce source
('A schematic procedure', 2, None, '___sec10'),
('A classification tree', 2, None, '___sec11'),
('Growing a classification tree', 2, None, '___sec12'),
- ('Back to moons again', 2, None, '___sec13'),
- ('Playing around with regions', 2, None, '___sec14'),
- ('Regression trees', 2, None, '___sec15'),
- ('Final regressor code', 2, None, '___sec16'),
- ('Classification again: The zoo data', 2, None, '___sec17'),
- ('Pros and cons of trees, pros', 2, None, '___sec18'),
- ('Disadvantages', 2, None, '___sec19'),
- ('Bagging', 2, None, '___sec20'),
- ('Simple example, head or tail', 2, None, '___sec21'),
- ('Random forests', 2, None, '___sec22'),
- ('A simple scikit-learn example', 2, None, '___sec23'),
- ('Please, not the moons again!', 2, None, '___sec24'),
- ('Bagging examples', 2, None, '___sec25'),
- ('Then random forests', 2, None, '___sec26'),
- ('Boosting and more', 2, None, '___sec27')]}
+ ('Classification tree, how to split nodes', 2, None, '___sec13'),
+ ('Back to moons again', 2, None, '___sec14'),
+ ('Playing around with regions', 2, None, '___sec15'),
+ ('Regression trees', 2, None, '___sec16'),
+ ('Final regressor code', 2, None, '___sec17'),
+ ('Classification again: The zoo data', 2, None, '___sec18'),
+ ('Pros and cons of trees, pros', 2, None, '___sec19'),
+ ('Disadvantages', 2, None, '___sec20'),
+ ('Bagging', 2, None, '___sec21'),
+ ('Simple example, head or tail', 2, None, '___sec22'),
+ ('Random forests', 2, None, '___sec23'),
+ ('A simple scikit-learn example', 2, None, '___sec24'),
+ ('Please, not the moons again!', 2, None, '___sec25'),
+ ('Bagging examples', 2, None, '___sec26'),
+ ('Then random forests', 2, None, '___sec27'),
+ ('Boosting and more', 2, None, '___sec28')]}
end of tocinfo -->
@@ -121,21 +122,22 @@ MathJax.Hub.Config({
A schematic procedure
A classification tree
Growing a classification tree
- Back to moons again
- Playing around with regions
- Regression trees
- Final regressor code
- Classification again: The zoo data
- Pros and cons of trees, pros
- Disadvantages
- Bagging
- Simple example, head or tail
- Random forests
- A simple scikit-learn example
- Please, not the moons again!
- Bagging examples
- Then random forests
- Boosting and more
+ Classification tree, how to split nodes
+ Back to moons again
+ Playing around with regions
+ Regression trees
+ Final regressor code
+ Classification again: The zoo data
+ Pros and cons of trees, pros
+ Disadvantages
+ Bagging
+ Simple example, head or tail
+ Random forests
+ A simple scikit-learn example
+ Please, not the moons again!
+ Bagging examples
+ Then random forests
+ Boosting and more
@@ -151,45 +153,23 @@ MathJax.Hub.Config({
-Random forests
-
+Simple example, head or tail
-Random forests provide an improvement over bagged trees by way of a
-small tweak that decorrelates the trees.
-
-
-As in bagging, we build a
-number of decision trees on bootstrapped training samples. But when
-building these decision trees, each time a split in a tree is
-considered, a random sample of \( m \) predictors is chosen as split
-candidates from the full set of \( p \) predictors. The split is allowed to
-use only one of those \( m \) predictors.
-
-
-A fresh sample of \( m \) predictors is
-taken at each split, and typically we choose
-$$
-m\approx \sqrt{p}.
-$$
-
-In building a random forest, at
-each split in the tree, the algorithm is not even allowed to consider
-a majority of the available predictors.
-
-
-The reason for this is rather clever. Suppose that there is one very
-strong predictor in the data set, along with a number of other
-moderately strong predictors. Then in the collection of bagged
-variable importance random forest trees, most or all of the trees will
-use this strong predictor in the top split. Consequently, all of the
-bagged trees will look quite similar to each other. Hence the
-predictions from the bagged trees will be highly correlated.
-Unfortunately, averaging many highly correlated quantities does not lead
-to as large of a reduction in variance as averaging many uncorrelated
-quanti- ties. In particular, this means that bagging will not lead to
-a substantial reduction in variance over a single tree in this
-setting.
+
+
heads_proba = 0.51
+coin_tosses = (np.random.rand(10000, 10) < heads_proba).astype(np.int32)
+cumulative_heads_ratio = np.cumsum(coin_tosses, axis=0) / np.arange(1, 10001).reshape(-1, 1)
+plt.figure(figsize=(8,3.5))
+plt.plot(cumulative_heads_ratio)
+plt.plot([0, 10000], [0.51, 0.51], "k--", linewidth=2, label="51%")
+plt.plot([0, 10000], [0.5, 0.5], "k-", label="50%")
+plt.xlabel("Number of coin tosses")
+plt.ylabel("Heads ratio")
+plt.legend(loc="lower right")
+plt.axis([0, 10000, 0.42, 0.58])
+plt.show()
+
@@ -211,6 +191,7 @@ setting.
27
28
29
+ 30
»
diff --git a/doc/pub/DecisionTrees/html/._DecisionTrees-bs024.html b/doc/pub/DecisionTrees/html/._DecisionTrees-bs024.html
index d942f8c95..1d971fb82 100644
--- a/doc/pub/DecisionTrees/html/._DecisionTrees-bs024.html
+++ b/doc/pub/DecisionTrees/html/._DecisionTrees-bs024.html
@@ -56,21 +56,22 @@ Automatically generated HTML file from DocOnce source
('A schematic procedure', 2, None, '___sec10'),
('A classification tree', 2, None, '___sec11'),
('Growing a classification tree', 2, None, '___sec12'),
- ('Back to moons again', 2, None, '___sec13'),
- ('Playing around with regions', 2, None, '___sec14'),
- ('Regression trees', 2, None, '___sec15'),
- ('Final regressor code', 2, None, '___sec16'),
- ('Classification again: The zoo data', 2, None, '___sec17'),
- ('Pros and cons of trees, pros', 2, None, '___sec18'),
- ('Disadvantages', 2, None, '___sec19'),
- ('Bagging', 2, None, '___sec20'),
- ('Simple example, head or tail', 2, None, '___sec21'),
- ('Random forests', 2, None, '___sec22'),
- ('A simple scikit-learn example', 2, None, '___sec23'),
- ('Please, not the moons again!', 2, None, '___sec24'),
- ('Bagging examples', 2, None, '___sec25'),
- ('Then random forests', 2, None, '___sec26'),
- ('Boosting and more', 2, None, '___sec27')]}
+ ('Classification tree, how to split nodes', 2, None, '___sec13'),
+ ('Back to moons again', 2, None, '___sec14'),
+ ('Playing around with regions', 2, None, '___sec15'),
+ ('Regression trees', 2, None, '___sec16'),
+ ('Final regressor code', 2, None, '___sec17'),
+ ('Classification again: The zoo data', 2, None, '___sec18'),
+ ('Pros and cons of trees, pros', 2, None, '___sec19'),
+ ('Disadvantages', 2, None, '___sec20'),
+ ('Bagging', 2, None, '___sec21'),
+ ('Simple example, head or tail', 2, None, '___sec22'),
+ ('Random forests', 2, None, '___sec23'),
+ ('A simple scikit-learn example', 2, None, '___sec24'),
+ ('Please, not the moons again!', 2, None, '___sec25'),
+ ('Bagging examples', 2, None, '___sec26'),
+ ('Then random forests', 2, None, '___sec27'),
+ ('Boosting and more', 2, None, '___sec28')]}
end of tocinfo -->
@@ -121,21 +122,22 @@ MathJax.Hub.Config({
A schematic procedure
A classification tree
Growing a classification tree
- Back to moons again
- Playing around with regions
- Regression trees
- Final regressor code
- Classification again: The zoo data
- Pros and cons of trees, pros
- Disadvantages
- Bagging
- Simple example, head or tail
- Random forests
- A simple scikit-learn example
- Please, not the moons again!
- Bagging examples
- Then random forests
- Boosting and more
+ Classification tree, how to split nodes
+ Back to moons again
+ Playing around with regions
+ Regression trees
+ Final regressor code
+ Classification again: The zoo data
+ Pros and cons of trees, pros
+ Disadvantages
+ Bagging
+ Simple example, head or tail
+ Random forests
+ A simple scikit-learn example
+ Please, not the moons again!
+ Bagging examples
+ Then random forests
+ Boosting and more
@@ -151,21 +153,45 @@ MathJax.Hub.Config({
-A simple scikit-learn example
-
+
Random forests
+
+
+Random forests provide an improvement over bagged trees by way of a
+small tweak that decorrelates the trees.
+
+
+As in bagging, we build a
+number of decision trees on bootstrapped training samples. But when
+building these decision trees, each time a split in a tree is
+considered, a random sample of \( m \) predictors is chosen as split
+candidates from the full set of \( p \) predictors. The split is allowed to
+use only one of those \( m \) predictors.
+
+
+A fresh sample of \( m \) predictors is
+taken at each split, and typically we choose
+$$
+m\approx \sqrt{p}.
+$$
+
+In building a random forest, at
+each split in the tree, the algorithm is not even allowed to consider
+a majority of the available predictors.
+
+
+The reason for this is rather clever. Suppose that there is one very
+strong predictor in the data set, along with a number of other
+moderately strong predictors. Then in the collection of bagged
+variable importance random forest trees, most or all of the trees will
+use this strong predictor in the top split. Consequently, all of the
+bagged trees will look quite similar to each other. Hence the
+predictions from the bagged trees will be highly correlated.
+Unfortunately, averaging many highly correlated quantities does not lead
+to as large of a reduction in variance as averaging many uncorrelated
+quanti- ties. In particular, this means that bagging will not lead to
+a substantial reduction in variance over a single tree in this
+setting.
-
-
from sklearn.ensemble import RandomForestClassifier
-from sklearn.preprocessing import LabelEncoder
-from sklearn.model_selection import cross_validate
-# Data set not specificied
-X = dataset.XXX
-Y = dataset.YYY
-#Instantiate the model with 100 trees and entropy as splitting criteria
-Random_Forest_model = RandomForestClassifier(n_estimators=100,criterion="entropy")
-#Cross validation
-accuracy = cross_validate(Random_Forest_model,X,Y,cv=10)['test_score']
-
@@ -186,6 +212,7 @@ accuracy = cross_validate(Random_Forest_mode
27
28
29
+ 30
»
diff --git a/doc/pub/DecisionTrees/html/._DecisionTrees-bs025.html b/doc/pub/DecisionTrees/html/._DecisionTrees-bs025.html
index 1b082ee4b..8b56b1b06 100644
--- a/doc/pub/DecisionTrees/html/._DecisionTrees-bs025.html
+++ b/doc/pub/DecisionTrees/html/._DecisionTrees-bs025.html
@@ -56,21 +56,22 @@ Automatically generated HTML file from DocOnce source
('A schematic procedure', 2, None, '___sec10'),
('A classification tree', 2, None, '___sec11'),
('Growing a classification tree', 2, None, '___sec12'),
- ('Back to moons again', 2, None, '___sec13'),
- ('Playing around with regions', 2, None, '___sec14'),
- ('Regression trees', 2, None, '___sec15'),
- ('Final regressor code', 2, None, '___sec16'),
- ('Classification again: The zoo data', 2, None, '___sec17'),
- ('Pros and cons of trees, pros', 2, None, '___sec18'),
- ('Disadvantages', 2, None, '___sec19'),
- ('Bagging', 2, None, '___sec20'),
- ('Simple example, head or tail', 2, None, '___sec21'),
- ('Random forests', 2, None, '___sec22'),
- ('A simple scikit-learn example', 2, None, '___sec23'),
- ('Please, not the moons again!', 2, None, '___sec24'),
- ('Bagging examples', 2, None, '___sec25'),
- ('Then random forests', 2, None, '___sec26'),
- ('Boosting and more', 2, None, '___sec27')]}
+ ('Classification tree, how to split nodes', 2, None, '___sec13'),
+ ('Back to moons again', 2, None, '___sec14'),
+ ('Playing around with regions', 2, None, '___sec15'),
+ ('Regression trees', 2, None, '___sec16'),
+ ('Final regressor code', 2, None, '___sec17'),
+ ('Classification again: The zoo data', 2, None, '___sec18'),
+ ('Pros and cons of trees, pros', 2, None, '___sec19'),
+ ('Disadvantages', 2, None, '___sec20'),
+ ('Bagging', 2, None, '___sec21'),
+ ('Simple example, head or tail', 2, None, '___sec22'),
+ ('Random forests', 2, None, '___sec23'),
+ ('A simple scikit-learn example', 2, None, '___sec24'),
+ ('Please, not the moons again!', 2, None, '___sec25'),
+ ('Bagging examples', 2, None, '___sec26'),
+ ('Then random forests', 2, None, '___sec27'),
+ ('Boosting and more', 2, None, '___sec28')]}
end of tocinfo -->
@@ -121,21 +122,22 @@ MathJax.Hub.Config({
A schematic procedure
A classification tree
Growing a classification tree
- Back to moons again
- Playing around with regions
- Regression trees
- Final regressor code
- Classification again: The zoo data
- Pros and cons of trees, pros
- Disadvantages
- Bagging
- Simple example, head or tail
- Random forests
- A simple scikit-learn example
- Please, not the moons again!
- Bagging examples
- Then random forests
- Boosting and more
+ Classification tree, how to split nodes
+ Back to moons again
+ Playing around with regions
+ Regression trees
+ Final regressor code
+ Classification again: The zoo data
+ Pros and cons of trees, pros
+ Disadvantages
+ Bagging
+ Simple example, head or tail
+ Random forests
+ A simple scikit-learn example
+ Please, not the moons again!
+ Bagging examples
+ Then random forests
+ Boosting and more
@@ -151,60 +153,20 @@ MathJax.Hub.Config({
-Please, not the moons again!
+A simple scikit-learn example
-
from sklearn.model_selection import train_test_split
-from sklearn.datasets import make_moons
-
-X, y = make_moons(n_samples=500, noise=0.30, random_state=42)
-X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
-from sklearn.ensemble import RandomForestClassifier
-from sklearn.ensemble import VotingClassifier
-from sklearn.linear_model import LogisticRegression
-from sklearn.svm import SVC
-
-log_clf = LogisticRegression(random_state=42)
-rnd_clf = RandomForestClassifier(random_state=42)
-svm_clf = SVC(random_state=42)
-
-voting_clf = VotingClassifier(
- estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
- voting='hard')
-voting_clf.fit(X_train, y_train)
-
-
-
-
-
from sklearn.metrics import accuracy_score
-
-for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
- clf.fit(X_train, y_train)
- y_pred = clf.predict(X_test)
- print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
-
-
-
-
-
log_clf = LogisticRegression(random_state=42)
-rnd_clf = RandomForestClassifier(random_state=42)
-svm_clf = SVC(probability=True, random_state=42)
-
-voting_clf = VotingClassifier(
- estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
- voting='soft')
-voting_clf.fit(X_train, y_train)
-
-
-
-
-
from sklearn.metrics import accuracy_score
-
-for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
- clf.fit(X_train, y_train)
- y_pred = clf.predict(X_test)
- print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
+from sklearn.ensemble import RandomForestClassifier
+from sklearn.preprocessing import LabelEncoder
+from sklearn.model_selection import cross_validate
+# Data set not specificied
+X = dataset.XXX
+Y = dataset.YYY
+#Instantiate the model with 100 trees and entropy as splitting criteria
+Random_Forest_model = RandomForestClassifier(n_estimators=100,criterion="entropy")
+#Cross validation
+accuracy = cross_validate(Random_Forest_model,X,Y,cv=10)['test_score']
@@ -225,6 +187,7 @@ voting_clf.fit(X_train, y_train)
27
28
29
+ 30
»
diff --git a/doc/pub/DecisionTrees/html/._DecisionTrees-bs026.html b/doc/pub/DecisionTrees/html/._DecisionTrees-bs026.html
index 7dc66df89..eb655212c 100644
--- a/doc/pub/DecisionTrees/html/._DecisionTrees-bs026.html
+++ b/doc/pub/DecisionTrees/html/._DecisionTrees-bs026.html
@@ -56,21 +56,22 @@ Automatically generated HTML file from DocOnce source
('A schematic procedure', 2, None, '___sec10'),
('A classification tree', 2, None, '___sec11'),
('Growing a classification tree', 2, None, '___sec12'),
- ('Back to moons again', 2, None, '___sec13'),
- ('Playing around with regions', 2, None, '___sec14'),
- ('Regression trees', 2, None, '___sec15'),
- ('Final regressor code', 2, None, '___sec16'),
- ('Classification again: The zoo data', 2, None, '___sec17'),
- ('Pros and cons of trees, pros', 2, None, '___sec18'),
- ('Disadvantages', 2, None, '___sec19'),
- ('Bagging', 2, None, '___sec20'),
- ('Simple example, head or tail', 2, None, '___sec21'),
- ('Random forests', 2, None, '___sec22'),
- ('A simple scikit-learn example', 2, None, '___sec23'),
- ('Please, not the moons again!', 2, None, '___sec24'),
- ('Bagging examples', 2, None, '___sec25'),
- ('Then random forests', 2, None, '___sec26'),
- ('Boosting and more', 2, None, '___sec27')]}
+ ('Classification tree, how to split nodes', 2, None, '___sec13'),
+ ('Back to moons again', 2, None, '___sec14'),
+ ('Playing around with regions', 2, None, '___sec15'),
+ ('Regression trees', 2, None, '___sec16'),
+ ('Final regressor code', 2, None, '___sec17'),
+ ('Classification again: The zoo data', 2, None, '___sec18'),
+ ('Pros and cons of trees, pros', 2, None, '___sec19'),
+ ('Disadvantages', 2, None, '___sec20'),
+ ('Bagging', 2, None, '___sec21'),
+ ('Simple example, head or tail', 2, None, '___sec22'),
+ ('Random forests', 2, None, '___sec23'),
+ ('A simple scikit-learn example', 2, None, '___sec24'),
+ ('Please, not the moons again!', 2, None, '___sec25'),
+ ('Bagging examples', 2, None, '___sec26'),
+ ('Then random forests', 2, None, '___sec27'),
+ ('Boosting and more', 2, None, '___sec28')]}
end of tocinfo -->
@@ -121,21 +122,22 @@ MathJax.Hub.Config({
A schematic procedure
A classification tree
Growing a classification tree
- Back to moons again
- Playing around with regions
- Regression trees
- Final regressor code
- Classification again: The zoo data
- Pros and cons of trees, pros
- Disadvantages
- Bagging
- Simple example, head or tail
- Random forests
- A simple scikit-learn example
- Please, not the moons again!
- Bagging examples
- Then random forests
- Boosting and more
+ Classification tree, how to split nodes
+ Back to moons again
+ Playing around with regions
+ Regression trees
+ Final regressor code
+ Classification again: The zoo data
+ Pros and cons of trees, pros
+ Disadvantages
+ Bagging
+ Simple example, head or tail
+ Random forests
+ A simple scikit-learn example
+ Please, not the moons again!
+ Bagging examples
+ Then random forests
+ Boosting and more
@@ -151,63 +153,60 @@ MathJax.Hub.Config({
-Bagging examples
-
+Please, not the moons again!
-
from sklearn.ensemble import BaggingClassifier
-from sklearn.tree import DecisionTreeClassifier
+from sklearn.model_selection import train_test_split
+from sklearn.datasets import make_moons
-bag_clf = BaggingClassifier(
- DecisionTreeClassifier(random_state=42), n_estimators=500,
- max_samples=100, bootstrap=True, n_jobs=-1, random_state=42)
-bag_clf.fit(X_train, y_train)
-y_pred = bag_clf.predict(X_test)
+X, y = make_moons(n_samples=500, noise=0.30, random_state=42)
+X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
+from sklearn.ensemble import RandomForestClassifier
+from sklearn.ensemble import VotingClassifier
+from sklearn.linear_model import LogisticRegression
+from sklearn.svm import SVC
+
+log_clf = LogisticRegression(random_state=42)
+rnd_clf = RandomForestClassifier(random_state=42)
+svm_clf = SVC(random_state=42)
+
+voting_clf = VotingClassifier(
+ estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
+ voting='hard')
+voting_clf.fit(X_train, y_train)
from sklearn.metrics import accuracy_score
-print(accuracy_score(y_test, y_pred))
+
+for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
+ clf.fit(X_train, y_train)
+ y_pred = clf.predict(X_test)
+ print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
-
tree_clf = DecisionTreeClassifier(random_state=42)
-tree_clf.fit(X_train, y_train)
-y_pred_tree = tree_clf.predict(X_test)
-print(accuracy_score(y_test, y_pred_tree))
+log_clf = LogisticRegression(random_state=42)
+rnd_clf = RandomForestClassifier(random_state=42)
+svm_clf = SVC(probability=True, random_state=42)
+
+voting_clf = VotingClassifier(
+ estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
+ voting='soft')
+voting_clf.fit(X_train, y_train)
-
from matplotlib.colors import ListedColormap
+from sklearn.metrics import accuracy_score
-def plot_decision_boundary(clf, X, y, axes=[-1.5, 2.5, -1, 1.5], alpha=0.5, contour=True):
- x1s = np.linspace(axes[0], axes[1], 100)
- x2s = np.linspace(axes[2], axes[3], 100)
- x1, x2 = np.meshgrid(x1s, x2s)
- X_new = np.c_[x1.ravel(), x2.ravel()]
- y_pred = clf.predict(X_new).reshape(x1.shape)
- custom_cmap = ListedColormap(['#fafab0','#9898ff','#a0faa0'])
- plt.contourf(x1, x2, y_pred, alpha=0.3, cmap=custom_cmap)
- if contour:
- custom_cmap2 = ListedColormap(['#7d7d58','#4c4c7f','#507d50'])
- plt.contour(x1, x2, y_pred, cmap=custom_cmap2, alpha=0.8)
- plt.plot(X[:, 0][y==0], X[:, 1][y==0], "yo", alpha=alpha)
- plt.plot(X[:, 0][y==1], X[:, 1][y==1], "bs", alpha=alpha)
- plt.axis(axes)
- plt.xlabel(r"$x_1$", fontsize=18)
- plt.ylabel(r"$x_2$", fontsize=18, rotation=0)
-plt.figure(figsize=(11,4))
-plt.subplot(121)
-plot_decision_boundary(tree_clf, X, y)
-plt.title("Decision Tree", fontsize=14)
-plt.subplot(122)
-plot_decision_boundary(bag_clf, X, y)
-plt.title("Decision Trees with Bagging", fontsize=14)
-plt.show()
+for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
+ clf.fit(X_train, y_train)
+ y_pred = clf.predict(X_test)
+ print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
@@ -227,6 +226,7 @@ plt.show()
27
28
29
+ 30
»
diff --git a/doc/pub/DecisionTrees/html/._DecisionTrees-bs027.html b/doc/pub/DecisionTrees/html/._DecisionTrees-bs027.html
index 2e4f05ceb..cbc21c2d6 100644
--- a/doc/pub/DecisionTrees/html/._DecisionTrees-bs027.html
+++ b/doc/pub/DecisionTrees/html/._DecisionTrees-bs027.html
@@ -56,21 +56,22 @@ Automatically generated HTML file from DocOnce source
('A schematic procedure', 2, None, '___sec10'),
('A classification tree', 2, None, '___sec11'),
('Growing a classification tree', 2, None, '___sec12'),
- ('Back to moons again', 2, None, '___sec13'),
- ('Playing around with regions', 2, None, '___sec14'),
- ('Regression trees', 2, None, '___sec15'),
- ('Final regressor code', 2, None, '___sec16'),
- ('Classification again: The zoo data', 2, None, '___sec17'),
- ('Pros and cons of trees, pros', 2, None, '___sec18'),
- ('Disadvantages', 2, None, '___sec19'),
- ('Bagging', 2, None, '___sec20'),
- ('Simple example, head or tail', 2, None, '___sec21'),
- ('Random forests', 2, None, '___sec22'),
- ('A simple scikit-learn example', 2, None, '___sec23'),
- ('Please, not the moons again!', 2, None, '___sec24'),
- ('Bagging examples', 2, None, '___sec25'),
- ('Then random forests', 2, None, '___sec26'),
- ('Boosting and more', 2, None, '___sec27')]}
+ ('Classification tree, how to split nodes', 2, None, '___sec13'),
+ ('Back to moons again', 2, None, '___sec14'),
+ ('Playing around with regions', 2, None, '___sec15'),
+ ('Regression trees', 2, None, '___sec16'),
+ ('Final regressor code', 2, None, '___sec17'),
+ ('Classification again: The zoo data', 2, None, '___sec18'),
+ ('Pros and cons of trees, pros', 2, None, '___sec19'),
+ ('Disadvantages', 2, None, '___sec20'),
+ ('Bagging', 2, None, '___sec21'),
+ ('Simple example, head or tail', 2, None, '___sec22'),
+ ('Random forests', 2, None, '___sec23'),
+ ('A simple scikit-learn example', 2, None, '___sec24'),
+ ('Please, not the moons again!', 2, None, '___sec25'),
+ ('Bagging examples', 2, None, '___sec26'),
+ ('Then random forests', 2, None, '___sec27'),
+ ('Boosting and more', 2, None, '___sec28')]}
end of tocinfo -->
@@ -121,21 +122,22 @@ MathJax.Hub.Config({
A schematic procedure
A classification tree
Growing a classification tree
- Back to moons again
- Playing around with regions
- Regression trees
- Final regressor code
- Classification again: The zoo data
- Pros and cons of trees, pros
- Disadvantages
- Bagging
- Simple example, head or tail
- Random forests
- A simple scikit-learn example
- Please, not the moons again!
- Bagging examples
- Then random forests
- Boosting and more
+ Classification tree, how to split nodes
+ Back to moons again
+ Playing around with regions
+ Regression trees
+ Final regressor code
+ Classification again: The zoo data
+ Pros and cons of trees, pros
+ Disadvantages
+ Bagging
+ Simple example, head or tail
+ Random forests
+ A simple scikit-learn example
+ Please, not the moons again!
+ Bagging examples
+ Then random forests
+ Boosting and more
@@ -151,24 +153,63 @@ MathJax.Hub.Config({
-Then random forests
+Bagging examples
+
-
bag_clf = BaggingClassifier(
- DecisionTreeClassifier(splitter="random", max_leaf_nodes=16, random_state=42),
- n_estimators=500, max_samples=1.0, bootstrap=True, n_jobs=-1, random_state=42)
+from sklearn.ensemble import BaggingClassifier
+from sklearn.tree import DecisionTreeClassifier
+
+bag_clf = BaggingClassifier(
+ DecisionTreeClassifier(random_state=42), n_estimators=500,
+ max_samples=100, bootstrap=True, n_jobs=-1, random_state=42)
+bag_clf.fit(X_train, y_train)
+y_pred = bag_clf.predict(X_test)
-
bag_clf.fit(X_train, y_train)
-y_pred = bag_clf.predict(X_test)
-from sklearn.ensemble import RandomForestClassifier
-rnd_clf = RandomForestClassifier(n_estimators=500, max_leaf_nodes=16, n_jobs=-1, random_state=42)
-rnd_clf.fit(X_train, y_train)
-y_pred_rf = rnd_clf.predict(X_test)
-np.sum(y_pred == y_pred_rf) / len(y_pred)
+from sklearn.metrics import accuracy_score
+print(accuracy_score(y_test, y_pred))
+
+
+
+
+
tree_clf = DecisionTreeClassifier(random_state=42)
+tree_clf.fit(X_train, y_train)
+y_pred_tree = tree_clf.predict(X_test)
+print(accuracy_score(y_test, y_pred_tree))
+
+
+
+
+
from matplotlib.colors import ListedColormap
+
+def plot_decision_boundary(clf, X, y, axes=[-1.5, 2.5, -1, 1.5], alpha=0.5, contour=True):
+ x1s = np.linspace(axes[0], axes[1], 100)
+ x2s = np.linspace(axes[2], axes[3], 100)
+ x1, x2 = np.meshgrid(x1s, x2s)
+ X_new = np.c_[x1.ravel(), x2.ravel()]
+ y_pred = clf.predict(X_new).reshape(x1.shape)
+ custom_cmap = ListedColormap(['#fafab0','#9898ff','#a0faa0'])
+ plt.contourf(x1, x2, y_pred, alpha=0.3, cmap=custom_cmap)
+ if contour:
+ custom_cmap2 = ListedColormap(['#7d7d58','#4c4c7f','#507d50'])
+ plt.contour(x1, x2, y_pred, cmap=custom_cmap2, alpha=0.8)
+ plt.plot(X[:, 0][y==0], X[:, 1][y==0], "yo", alpha=alpha)
+ plt.plot(X[:, 0][y==1], X[:, 1][y==1], "bs", alpha=alpha)
+ plt.axis(axes)
+ plt.xlabel(r"$x_1$", fontsize=18)
+ plt.ylabel(r"$x_2$", fontsize=18, rotation=0)
+plt.figure(figsize=(11,4))
+plt.subplot(121)
+plot_decision_boundary(tree_clf, X, y)
+plt.title("Decision Tree", fontsize=14)
+plt.subplot(122)
+plot_decision_boundary(bag_clf, X, y)
+plt.title("Decision Trees with Bagging", fontsize=14)
+plt.show()
@@ -187,6 +228,7 @@ np.sum(y_pred =
27
28
29
+ 30
»
diff --git a/doc/pub/DecisionTrees/html/._DecisionTrees-bs028.html b/doc/pub/DecisionTrees/html/._DecisionTrees-bs028.html
index 1c8ec847d..a1cd7a19d 100644
--- a/doc/pub/DecisionTrees/html/._DecisionTrees-bs028.html
+++ b/doc/pub/DecisionTrees/html/._DecisionTrees-bs028.html
@@ -56,21 +56,22 @@ Automatically generated HTML file from DocOnce source
('A schematic procedure', 2, None, '___sec10'),
('A classification tree', 2, None, '___sec11'),
('Growing a classification tree', 2, None, '___sec12'),
- ('Back to moons again', 2, None, '___sec13'),
- ('Playing around with regions', 2, None, '___sec14'),
- ('Regression trees', 2, None, '___sec15'),
- ('Final regressor code', 2, None, '___sec16'),
- ('Classification again: The zoo data', 2, None, '___sec17'),
- ('Pros and cons of trees, pros', 2, None, '___sec18'),
- ('Disadvantages', 2, None, '___sec19'),
- ('Bagging', 2, None, '___sec20'),
- ('Simple example, head or tail', 2, None, '___sec21'),
- ('Random forests', 2, None, '___sec22'),
- ('A simple scikit-learn example', 2, None, '___sec23'),
- ('Please, not the moons again!', 2, None, '___sec24'),
- ('Bagging examples', 2, None, '___sec25'),
- ('Then random forests', 2, None, '___sec26'),
- ('Boosting and more', 2, None, '___sec27')]}
+ ('Classification tree, how to split nodes', 2, None, '___sec13'),
+ ('Back to moons again', 2, None, '___sec14'),
+ ('Playing around with regions', 2, None, '___sec15'),
+ ('Regression trees', 2, None, '___sec16'),
+ ('Final regressor code', 2, None, '___sec17'),
+ ('Classification again: The zoo data', 2, None, '___sec18'),
+ ('Pros and cons of trees, pros', 2, None, '___sec19'),
+ ('Disadvantages', 2, None, '___sec20'),
+ ('Bagging', 2, None, '___sec21'),
+ ('Simple example, head or tail', 2, None, '___sec22'),
+ ('Random forests', 2, None, '___sec23'),
+ ('A simple scikit-learn example', 2, None, '___sec24'),
+ ('Please, not the moons again!', 2, None, '___sec25'),
+ ('Bagging examples', 2, None, '___sec26'),
+ ('Then random forests', 2, None, '___sec27'),
+ ('Boosting and more', 2, None, '___sec28')]}
end of tocinfo -->
@@ -121,21 +122,22 @@ MathJax.Hub.Config({
A schematic procedure
A classification tree
Growing a classification tree
- Back to moons again
- Playing around with regions
- Regression trees
- Final regressor code
- Classification again: The zoo data
- Pros and cons of trees, pros
- Disadvantages
- Bagging
- Simple example, head or tail
- Random forests
- A simple scikit-learn example
- Please, not the moons again!
- Bagging examples
- Then random forests
- Boosting and more
+ Classification tree, how to split nodes
+ Back to moons again
+ Playing around with regions
+ Regression trees
+ Final regressor code
+ Classification again: The zoo data
+ Pros and cons of trees, pros
+ Disadvantages
+ Bagging
+ Simple example, head or tail
+ Random forests
+ A simple scikit-learn example
+ Please, not the moons again!
+ Bagging examples
+ Then random forests
+ Boosting and more
@@ -149,11 +151,28 @@ MathJax.Hub.Config({
-
+
-Boosting and more
-More material to come here.
+Then random forests
+
+
+
bag_clf = BaggingClassifier(
+ DecisionTreeClassifier(splitter="random", max_leaf_nodes=16, random_state=42),
+ n_estimators=500, max_samples=1.0, bootstrap=True, n_jobs=-1, random_state=42)
+
+
+
+
+
bag_clf.fit(X_train, y_train)
+y_pred = bag_clf.predict(X_test)
+from sklearn.ensemble import RandomForestClassifier
+rnd_clf = RandomForestClassifier(n_estimators=500, max_leaf_nodes=16, n_jobs=-1, random_state=42)
+rnd_clf.fit(X_train, y_train)
+y_pred_rf = rnd_clf.predict(X_test)
+np.sum(y_pred == y_pred_rf) / len(y_pred)
+
+
diff --git a/doc/pub/DecisionTrees/html/DecisionTrees-bs.html b/doc/pub/DecisionTrees/html/DecisionTrees-bs.html
index f26bb4feb..1c0439170 100644
--- a/doc/pub/DecisionTrees/html/DecisionTrees-bs.html
+++ b/doc/pub/DecisionTrees/html/DecisionTrees-bs.html
@@ -56,21 +56,22 @@ Automatically generated HTML file from DocOnce source
('A schematic procedure', 2, None, '___sec10'),
('A classification tree', 2, None, '___sec11'),
('Growing a classification tree', 2, None, '___sec12'),
- ('Back to moons again', 2, None, '___sec13'),
- ('Playing around with regions', 2, None, '___sec14'),
- ('Regression trees', 2, None, '___sec15'),
- ('Final regressor code', 2, None, '___sec16'),
- ('Classification again: The zoo data', 2, None, '___sec17'),
- ('Pros and cons of trees, pros', 2, None, '___sec18'),
- ('Disadvantages', 2, None, '___sec19'),
- ('Bagging', 2, None, '___sec20'),
- ('Simple example, head or tail', 2, None, '___sec21'),
- ('Random forests', 2, None, '___sec22'),
- ('A simple scikit-learn example', 2, None, '___sec23'),
- ('Please, not the moons again!', 2, None, '___sec24'),
- ('Bagging examples', 2, None, '___sec25'),
- ('Then random forests', 2, None, '___sec26'),
- ('Boosting and more', 2, None, '___sec27')]}
+ ('Classification tree, how to split nodes', 2, None, '___sec13'),
+ ('Back to moons again', 2, None, '___sec14'),
+ ('Playing around with regions', 2, None, '___sec15'),
+ ('Regression trees', 2, None, '___sec16'),
+ ('Final regressor code', 2, None, '___sec17'),
+ ('Classification again: The zoo data', 2, None, '___sec18'),
+ ('Pros and cons of trees, pros', 2, None, '___sec19'),
+ ('Disadvantages', 2, None, '___sec20'),
+ ('Bagging', 2, None, '___sec21'),
+ ('Simple example, head or tail', 2, None, '___sec22'),
+ ('Random forests', 2, None, '___sec23'),
+ ('A simple scikit-learn example', 2, None, '___sec24'),
+ ('Please, not the moons again!', 2, None, '___sec25'),
+ ('Bagging examples', 2, None, '___sec26'),
+ ('Then random forests', 2, None, '___sec27'),
+ ('Boosting and more', 2, None, '___sec28')]}
end of tocinfo -->
@@ -121,21 +122,22 @@ MathJax.Hub.Config({
A schematic procedure
A classification tree
Growing a classification tree
- Back to moons again
- Playing around with regions
- Regression trees
- Final regressor code
- Classification again: The zoo data
- Pros and cons of trees, pros
- Disadvantages
- Bagging
- Simple example, head or tail
- Random forests
- A simple scikit-learn example
- Please, not the moons again!
- Bagging examples
- Then random forests
- Boosting and more
+ Classification tree, how to split nodes
+ Back to moons again
+ Playing around with regions
+ Regression trees
+ Final regressor code
+ Classification again: The zoo data
+ Pros and cons of trees, pros
+ Disadvantages
+ Bagging
+ Simple example, head or tail
+ Random forests
+ A simple scikit-learn example
+ Please, not the moons again!
+ Bagging examples
+ Then random forests
+ Boosting and more
@@ -170,7 +172,7 @@ MathJax.Hub.Config({
[2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University
-
Nov 9, 2018
+Nov 10, 2018
@@ -194,7 +196,7 @@ MathJax.Hub.Config({
9
10
...
- 29
+ 30
»
diff --git a/doc/pub/DecisionTrees/html/DecisionTrees-reveal.html b/doc/pub/DecisionTrees/html/DecisionTrees-reveal.html
index 923147354..6830e82dc 100644
--- a/doc/pub/DecisionTrees/html/DecisionTrees-reveal.html
+++ b/doc/pub/DecisionTrees/html/DecisionTrees-reveal.html
@@ -148,7 +148,7 @@ MathJax.Hub.Config({
[2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University
-
Nov 9, 2018
+Nov 10, 2018
@@ -653,7 +653,14 @@ than is the classification error rate.
-Back to moons again
+Classification tree, how to split nodes
+If our targets are the outcome of a classification process that takes for example
+\( k=1,2,\dots,K \) values, the only thing we need to think of is to set up the splitting criteria for each node.
+
+
+
+
+Back to moons again
@@ -726,7 +733,7 @@ plt.show()
-Playing around with regions
+Playing around with regions
@@ -755,7 +762,7 @@ plt.show()
-Regression trees
+Regression trees
@@ -778,7 +785,7 @@ tree_reg.fit(X, y)
-Final regressor code
+Final regressor code
@@ -857,7 +864,7 @@ plt.show()
-Classification again: The zoo data
+Classification again: The zoo data
@@ -886,7 +893,7 @@ prediction = tree.predict(test_features)
-Pros and cons of trees, pros
+Pros and cons of trees, pros
- White box, easy to interpret model. Some people believe that decision trees more closely mirror human decision-making than do the regression and classification approaches discussed earlier (think of support vector machines)
@@ -901,7 +908,7 @@ prediction = tree.predict(test_features)
-Disadvantages
+Disadvantages
- Unfortunately, trees generally do not have the same level of predictive accuracy as some of the other regression and classification approaches
@@ -919,7 +926,7 @@ However, by aggregating many decision trees, using methods like bagging, random
-Bagging
+Bagging
The plain decision trees suffer from high
@@ -962,7 +969,7 @@ predictor, averaged over all \( B \) trees.
-Simple example, head or tail
+Simple example, head or tail
@@ -983,7 +990,7 @@ plt.show()
-Random forests
+Random forests
Random forests provide an improvement over bagged trees by way of a
@@ -1027,7 +1034,7 @@ setting.
-A simple scikit-learn example
+A simple scikit-learn example
@@ -1046,7 +1053,7 @@ accuracy = cross_validate(Random_Forest_model,X,Y,cv=Please, not the moons again!
+Please, not the moons again!
@@ -1105,7 +1112,7 @@ voting_clf.fit(X_train, y_train)
-Bagging examples
+Bagging examples
@@ -1167,7 +1174,7 @@ plt.show()
-Then random forests
+Then random forests
@@ -1190,7 +1197,7 @@ np.sum(y_pred == y_pred_rf) / len(y_pred)
-Boosting and more
+Boosting and more
More material to come here.
diff --git a/doc/pub/DecisionTrees/html/DecisionTrees-solarized.html b/doc/pub/DecisionTrees/html/DecisionTrees-solarized.html
index bd38d76e7..2c52a2dc3 100644
--- a/doc/pub/DecisionTrees/html/DecisionTrees-solarized.html
+++ b/doc/pub/DecisionTrees/html/DecisionTrees-solarized.html
@@ -76,21 +76,22 @@ div { text-align: justify; text-justify: inter-word; }
('A schematic procedure', 2, None, '___sec10'),
('A classification tree', 2, None, '___sec11'),
('Growing a classification tree', 2, None, '___sec12'),
- ('Back to moons again', 2, None, '___sec13'),
- ('Playing around with regions', 2, None, '___sec14'),
- ('Regression trees', 2, None, '___sec15'),
- ('Final regressor code', 2, None, '___sec16'),
- ('Classification again: The zoo data', 2, None, '___sec17'),
- ('Pros and cons of trees, pros', 2, None, '___sec18'),
- ('Disadvantages', 2, None, '___sec19'),
- ('Bagging', 2, None, '___sec20'),
- ('Simple example, head or tail', 2, None, '___sec21'),
- ('Random forests', 2, None, '___sec22'),
- ('A simple scikit-learn example', 2, None, '___sec23'),
- ('Please, not the moons again!', 2, None, '___sec24'),
- ('Bagging examples', 2, None, '___sec25'),
- ('Then random forests', 2, None, '___sec26'),
- ('Boosting and more', 2, None, '___sec27')]}
+ ('Classification tree, how to split nodes', 2, None, '___sec13'),
+ ('Back to moons again', 2, None, '___sec14'),
+ ('Playing around with regions', 2, None, '___sec15'),
+ ('Regression trees', 2, None, '___sec16'),
+ ('Final regressor code', 2, None, '___sec17'),
+ ('Classification again: The zoo data', 2, None, '___sec18'),
+ ('Pros and cons of trees, pros', 2, None, '___sec19'),
+ ('Disadvantages', 2, None, '___sec20'),
+ ('Bagging', 2, None, '___sec21'),
+ ('Simple example, head or tail', 2, None, '___sec22'),
+ ('Random forests', 2, None, '___sec23'),
+ ('A simple scikit-learn example', 2, None, '___sec24'),
+ ('Please, not the moons again!', 2, None, '___sec25'),
+ ('Bagging examples', 2, None, '___sec26'),
+ ('Then random forests', 2, None, '___sec27'),
+ ('Boosting and more', 2, None, '___sec28')]}
end of tocinfo -->
@@ -132,7 +133,7 @@ MathJax.Hub.Config({
[2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University
-
Nov 9, 2018
+Nov 10, 2018
@@ -620,7 +621,14 @@ than is the classification error rate.
-
Back to moons again
+Classification tree, how to split nodes
+If our targets are the outcome of a classification process that takes for example
+\( k=1,2,\dots,K \) values, the only thing we need to think of is to set up the splitting criteria for each node.
+
+
+
+
+
Back to moons again
@@ -692,7 +700,7 @@ plt.show()
-
Playing around with regions
+Playing around with regions
@@ -720,7 +728,7 @@ plt.show()
-
Regression trees
+Regression trees
@@ -742,7 +750,7 @@ tree_reg.fit(X, y)
-
Final regressor code
+Final regressor code
@@ -820,7 +828,7 @@ plt.show()
-
Classification again: The zoo data
+Classification again: The zoo data
@@ -848,7 +856,7 @@ prediction = tree.predict(test_features)
-
Pros and cons of trees, pros
+Pros and cons of trees, pros
- White box, easy to interpret model. Some people believe that decision trees more closely mirror human decision-making than do the regression and classification approaches discussed earlier (think of support vector machines)
@@ -862,7 +870,7 @@ prediction = tree.predict(test_features)
-Disadvantages
+Disadvantages
- Unfortunately, trees generally do not have the same level of predictive accuracy as some of the other regression and classification approaches
@@ -879,7 +887,7 @@ However, by aggregating many decision trees, using methods like bagging, random
-
Bagging
+Bagging
The plain decision trees suffer from high
@@ -922,7 +930,7 @@ predictor, averaged over all \( B \) trees.
-
Simple example, head or tail
+Simple example, head or tail
@@ -942,7 +950,7 @@ plt.show()
-
Random forests
+Random forests
Random forests provide an improvement over bagged trees by way of a
@@ -984,7 +992,7 @@ setting.
-
A simple scikit-learn example
+A simple scikit-learn example
@@ -1002,7 +1010,7 @@ accuracy = cross_validate(Random_Forest_model,X,Y,cv=Please, not the moons again!
+Please, not the moons again!
@@ -1060,7 +1068,7 @@ voting_clf.fit(X_train, y_train)
-
Bagging examples
+Bagging examples
@@ -1121,7 +1129,7 @@ plt.show()
-
Then random forests
+Then random forests
@@ -1143,7 +1151,7 @@ np.sum(y_pred == y_pred_rf) / len(y_pred)
-
Boosting and more
+Boosting and more
More material to come here.
diff --git a/doc/pub/DecisionTrees/html/DecisionTrees.html b/doc/pub/DecisionTrees/html/DecisionTrees.html
index 1b62ed366..91f56040b 100644
--- a/doc/pub/DecisionTrees/html/DecisionTrees.html
+++ b/doc/pub/DecisionTrees/html/DecisionTrees.html
@@ -81,21 +81,22 @@ div { text-align: justify; text-justify: inter-word; }
('A schematic procedure', 2, None, '___sec10'),
('A classification tree', 2, None, '___sec11'),
('Growing a classification tree', 2, None, '___sec12'),
- ('Back to moons again', 2, None, '___sec13'),
- ('Playing around with regions', 2, None, '___sec14'),
- ('Regression trees', 2, None, '___sec15'),
- ('Final regressor code', 2, None, '___sec16'),
- ('Classification again: The zoo data', 2, None, '___sec17'),
- ('Pros and cons of trees, pros', 2, None, '___sec18'),
- ('Disadvantages', 2, None, '___sec19'),
- ('Bagging', 2, None, '___sec20'),
- ('Simple example, head or tail', 2, None, '___sec21'),
- ('Random forests', 2, None, '___sec22'),
- ('A simple scikit-learn example', 2, None, '___sec23'),
- ('Please, not the moons again!', 2, None, '___sec24'),
- ('Bagging examples', 2, None, '___sec25'),
- ('Then random forests', 2, None, '___sec26'),
- ('Boosting and more', 2, None, '___sec27')]}
+ ('Classification tree, how to split nodes', 2, None, '___sec13'),
+ ('Back to moons again', 2, None, '___sec14'),
+ ('Playing around with regions', 2, None, '___sec15'),
+ ('Regression trees', 2, None, '___sec16'),
+ ('Final regressor code', 2, None, '___sec17'),
+ ('Classification again: The zoo data', 2, None, '___sec18'),
+ ('Pros and cons of trees, pros', 2, None, '___sec19'),
+ ('Disadvantages', 2, None, '___sec20'),
+ ('Bagging', 2, None, '___sec21'),
+ ('Simple example, head or tail', 2, None, '___sec22'),
+ ('Random forests', 2, None, '___sec23'),
+ ('A simple scikit-learn example', 2, None, '___sec24'),
+ ('Please, not the moons again!', 2, None, '___sec25'),
+ ('Bagging examples', 2, None, '___sec26'),
+ ('Then random forests', 2, None, '___sec27'),
+ ('Boosting and more', 2, None, '___sec28')]}
end of tocinfo -->
@@ -137,7 +138,7 @@ MathJax.Hub.Config({
[2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University
-
Nov 9, 2018
+Nov 10, 2018
@@ -625,7 +626,14 @@ than is the classification error rate.
-
Back to moons again
+Classification tree, how to split nodes
+If our targets are the outcome of a classification process that takes for example
+\( k=1,2,\dots,K \) values, the only thing we need to think of is to set up the splitting criteria for each node.
+
+
+
+
+
Back to moons again
@@ -697,7 +705,7 @@ plt.show()
-
Playing around with regions
+Playing around with regions
@@ -725,7 +733,7 @@ plt.show()
-
Regression trees
+Regression trees
@@ -747,7 +755,7 @@ tree_reg.fit(X, y)
-
Final regressor code
+Final regressor code
@@ -825,7 +833,7 @@ plt.show()
-
Classification again: The zoo data
+Classification again: The zoo data
@@ -853,7 +861,7 @@ prediction = treePros and cons of trees, pros
+Pros and cons of trees, pros
- White box, easy to interpret model. Some people believe that decision trees more closely mirror human decision-making than do the regression and classification approaches discussed earlier (think of support vector machines)
@@ -867,7 +875,7 @@ prediction = treeDisadvantages
+Disadvantages
- Unfortunately, trees generally do not have the same level of predictive accuracy as some of the other regression and classification approaches
@@ -884,7 +892,7 @@ However, by aggregating many decision trees, using methods like bagging, random
-
Bagging
+Bagging
The plain decision trees suffer from high
@@ -927,7 +935,7 @@ predictor, averaged over all \( B \) trees.
-
Simple example, head or tail
+Simple example, head or tail
@@ -947,7 +955,7 @@ plt.show()
-
Random forests
+Random forests
Random forests provide an improvement over bagged trees by way of a
@@ -989,7 +997,7 @@ setting.
-
A simple scikit-learn example
+A simple scikit-learn example
@@ -1007,7 +1015,7 @@ accuracy = cross_validate(Random_Forest_mode
-
Please, not the moons again!
+Please, not the moons again!
@@ -1065,7 +1073,7 @@ voting_clf.fit(X_train, y_train)
-
Bagging examples
+Bagging examples
@@ -1126,7 +1134,7 @@ plt.show()
-
Then random forests
+Then random forests
@@ -1148,7 +1156,7 @@ np.sum(y_pred =
-
Boosting and more
+Boosting and more
More material to come here.
diff --git a/doc/pub/DecisionTrees/ipynb/ipynb-DecisionTrees-src.tar.gz b/doc/pub/DecisionTrees/ipynb/ipynb-DecisionTrees-src.tar.gz
index 887113c3e..651877f89 100644
Binary files a/doc/pub/DecisionTrees/ipynb/ipynb-DecisionTrees-src.tar.gz and b/doc/pub/DecisionTrees/ipynb/ipynb-DecisionTrees-src.tar.gz differ
diff --git a/doc/pub/DecisionTrees/pdf/DecisionTrees-minted.pdf b/doc/pub/DecisionTrees/pdf/DecisionTrees-minted.pdf
index ff3d3a3cd..8eb940865 100644
Binary files a/doc/pub/DecisionTrees/pdf/DecisionTrees-minted.pdf and b/doc/pub/DecisionTrees/pdf/DecisionTrees-minted.pdf differ
diff --git a/doc/src/Autoencoders/Autoencoders.do.txt b/doc/src/Autoencoders/Autoencoders.do.txt
new file mode 100644
index 000000000..ef7582293
--- /dev/null
+++ b/doc/src/Autoencoders/Autoencoders.do.txt
@@ -0,0 +1,7 @@
+TITLE: Data Analysis and Machine Learning: Autoencoders
+AUTHOR: Morten Hjorth-Jensen {copyright, 1999-present|CC BY-NC} at Department of Physics, University of Oslo & Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University
+DATE: today
+
+
+!split
+===== Autoencoders: Overarching view =====
diff --git a/doc/src/Autoencoders/clean.sh b/doc/src/Autoencoders/clean.sh
new file mode 100755
index 000000000..2e5da2c72
--- /dev/null
+++ b/doc/src/Autoencoders/clean.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+doconce clean
+rm -rf *.pdf *.tex ipynb*.tar.gz *.html ._*.html *~ reveal.js Trash README.txt
diff --git a/doc/src/Autoencoders/make.sh b/doc/src/Autoencoders/make.sh
new file mode 100755
index 000000000..d908b90b9
--- /dev/null
+++ b/doc/src/Autoencoders/make.sh
@@ -0,0 +1,95 @@
+#!/bin/sh
+set -x
+
+function system {
+ "$@"
+ if [ $? -ne 0 ]; then
+ echo "make.sh: unsuccessful command $@"
+ echo "abort!"
+ exit 1
+ fi
+}
+
+if [ $# -eq 0 ]; then
+echo 'bash make.sh slides1|slides2'
+exit 1
+fi
+
+name=$1
+rm -f *.tar.gz
+
+opt="--encoding=utf-8"
+# Note: Makefile examples contain constructions like ${PROG} which
+# looks like Mako constructions, but they are not. Use --no_mako
+# to turn off Mako processing.
+opt="--no_mako"
+
+rm -f *.aux
+
+
+html=${name}-reveal
+system doconce format html $name --pygments_html_style=perldoc --keep_pygments_html_bg --html_links_in_new_window --html_output=$html $opt
+system doconce slides_html $html reveal --html_slide_theme=beige
+
+# Plain HTML documents
+
+html=${name}-solarized
+system doconce format html $name --pygments_html_style=perldoc --html_style=solarized3 --html_links_in_new_window --html_output=$html $opt
+system doconce split_html $html.html --method=space10
+
+html=${name}
+system doconce format html $name --pygments_html_style=default --html_style=bloodish --html_links_in_new_window --html_output=$html $opt
+system doconce split_html $html.html --method=space10
+
+# Bootstrap style
+html=${name}-bs
+system doconce format html $name --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=$html $opt
+system doconce split_html $html.html --method=split --pagination --nav_button=bottom
+
+# IPython notebook
+system doconce format ipynb $name $opt
+
+
+# Ordinary plain LaTeX document
+rm -f *.aux # important after beamer
+system doconce format pdflatex $name --minted_latex_style=trac --latex_admon=paragraph $opt
+system doconce ptex2tex $name envir=minted
+# Add special packages
+doconce subst "% Add user's preamble" "\g<1>\n\\usepackage{simplewick}" $name.tex
+doconce replace 'section{' 'section*{' $name.tex
+pdflatex -shell-escape $name
+pdflatex -shell-escape $name
+mv -f $name.pdf ${name}-minted.pdf
+cp $name.tex ${name}-plain-minted.tex
+
+
+
+# Publish
+dest=../../pub
+if [ ! -d $dest/$name ]; then
+mkdir $dest/$name
+mkdir $dest/$name/pdf
+mkdir $dest/$name/html
+mkdir $dest/$name/ipynb
+fi
+cp ${name}*.pdf $dest/$name/pdf
+cp -r ${name}*.html ._${name}*.html reveal.js $dest/$name/html
+
+# Figures: cannot just copy link, need to physically copy the files
+if [ -d fig-${name} ]; then
+if [ ! -d $dest/$name/html/fig-$name ]; then
+mkdir $dest/$name/html/fig-$name
+fi
+cp -r fig-${name}/* $dest/$name/html/fig-$name
+fi
+
+cp ${name}.ipynb $dest/$name/ipynb
+ipynb_tarfile=ipynb-${name}-src.tar.gz
+if [ ! -f ${ipynb_tarfile} ]; then
+cat > README.txt <\n\\usepackage{simplewick}" $name.tex
+doconce replace 'section{' 'section*{' $name.tex
+pdflatex -shell-escape $name
+pdflatex -shell-escape $name
+mv -f $name.pdf ${name}-minted.pdf
+cp $name.tex ${name}-plain-minted.tex
+
+
+
+# Publish
+dest=../../pub
+if [ ! -d $dest/$name ]; then
+mkdir $dest/$name
+mkdir $dest/$name/pdf
+mkdir $dest/$name/html
+mkdir $dest/$name/ipynb
+fi
+cp ${name}*.pdf $dest/$name/pdf
+cp -r ${name}*.html ._${name}*.html reveal.js $dest/$name/html
+
+# Figures: cannot just copy link, need to physically copy the files
+if [ -d fig-${name} ]; then
+if [ ! -d $dest/$name/html/fig-$name ]; then
+mkdir $dest/$name/html/fig-$name
+fi
+cp -r fig-${name}/* $dest/$name/html/fig-$name
+fi
+
+cp ${name}.ipynb $dest/$name/ipynb
+ipynb_tarfile=ipynb-${name}-src.tar.gz
+if [ ! -f ${ipynb_tarfile} ]; then
+cat > README.txt <\n\\usepackage{simplewick}" $name.tex
+doconce replace 'section{' 'section*{' $name.tex
+pdflatex -shell-escape $name
+pdflatex -shell-escape $name
+mv -f $name.pdf ${name}-minted.pdf
+cp $name.tex ${name}-plain-minted.tex
+
+
+
+# Publish
+dest=../../pub
+if [ ! -d $dest/$name ]; then
+mkdir $dest/$name
+mkdir $dest/$name/pdf
+mkdir $dest/$name/html
+mkdir $dest/$name/ipynb
+fi
+cp ${name}*.pdf $dest/$name/pdf
+cp -r ${name}*.html ._${name}*.html reveal.js $dest/$name/html
+
+# Figures: cannot just copy link, need to physically copy the files
+if [ -d fig-${name} ]; then
+if [ ! -d $dest/$name/html/fig-$name ]; then
+mkdir $dest/$name/html/fig-$name
+fi
+cp -r fig-${name}/* $dest/$name/html/fig-$name
+fi
+
+cp ${name}.ipynb $dest/$name/ipynb
+ipynb_tarfile=ipynb-${name}-src.tar.gz
+if [ ! -f ${ipynb_tarfile} ]; then
+cat > README.txt <
diff --git a/doc/web/course.html b/doc/web/course.html
index fcc56918f..d12071108 100644
--- a/doc/web/course.html
+++ b/doc/web/course.html
@@ -82,45 +82,48 @@ div { text-align: justify; text-justify: inter-word; }
2,
None,
'___sec4'),
- ('Gradient methods', 2, None, '___sec5'),
- ('Regression Methods', 2, None, '___sec6'),
+ ('Regression Methods', 2, None, '___sec5'),
+ ('Gradient methods', 2, None, '___sec6'),
('Logistic Regression', 2, None, '___sec7'),
('Neural Networks', 2, None, '___sec8'),
('Reduction of dimensionality', 2, None, '___sec9'),
- ('Elements of Bayesian theory', 2, None, '___sec10'),
('Decision trees, from simple to random ones',
2,
None,
- '___sec11'),
- ('Support Vector Machines', 2, None, '___sec12'),
+ '___sec10'),
+ ('Support Vector Machines', 2, None, '___sec11'),
('Unsupervised Learning, Boltzmann Machines',
2,
None,
- '___sec13'),
- ('Python and Scikit Learn, a short guide', 2, None, '___sec14'),
- ('Teach yourself C++', 2, None, '___sec15'),
- ('Projects and Exercises Fall 2018', 2, None, '___sec16'),
- ('First homework set, week 35', 3, None, '___sec17'),
- ('Second homework set, week 36', 3, None, '___sec18'),
- ('Project 1, Deadline October 1', 3, None, '___sec19'),
- ('Project 2, Deadline November 5', 3, None, '___sec20'),
- ('Project 3, Deadline December 10', 3, None, '___sec21'),
- ('Course content', 3, None, '___sec22'),
- ('Learning outcomes', 2, None, '___sec23'),
- ('Prerequisites', 2, None, '___sec24'),
- ('The course has two central parts', 2, None, '___sec25'),
+ '___sec12'),
+ ('Recurrent Neural Networks', 2, None, '___sec13'),
+ ('Autoencoders', 2, None, '___sec14'),
+ ('Reinforcement Learning', 2, None, '___sec15'),
+ ('Elements of Bayesian theory', 2, None, '___sec16'),
+ ('Python and Scikit Learn, a short guide', 2, None, '___sec17'),
+ ('Teach yourself C++', 2, None, '___sec18'),
+ ('Projects and Exercises Fall 2018', 2, None, '___sec19'),
+ ('First homework set, week 35', 3, None, '___sec20'),
+ ('Second homework set, week 36', 3, None, '___sec21'),
+ ('Project 1, Deadline October 1', 3, None, '___sec22'),
+ ('Project 2, Deadline November 5', 3, None, '___sec23'),
+ ('Project 3, Deadline December 10', 3, None, '___sec24'),
+ ('Course content', 3, None, '___sec25'),
+ ('Learning outcomes', 2, None, '___sec26'),
+ ('Prerequisites', 2, None, '___sec27'),
+ ('The course has two central parts', 2, None, '___sec28'),
('Statistical analysis and optimization of data',
3,
None,
- '___sec26'),
- ('Machine learning', 3, None, '___sec27'),
- ('Recommended textbooks', 2, None, '___sec28'),
+ '___sec29'),
+ ('Machine learning', 3, None, '___sec30'),
+ ('Recommended textbooks', 2, None, '___sec31'),
('"Other '
'textbooks":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Textbooks"',
2,
None,
- '___sec29'),
- ('Teaching schedule Fall 2018', 2, None, '___sec30')]}
+ '___sec32'),
+ ('Teaching schedule Fall 2018', 2, None, '___sec33')]}
end of tocinfo -->
@@ -328,36 +331,7 @@ formulas in HTML or ipython notebook files.
-Gradient methods
-
-
- - LaTeX PDF:
-
-
- - For printing:
-
-
-
-
-
- - HTML:
-
-
-
- - Jupyter notebook:
-
-
- - ipynb file
-
-
-
-
-Regression Methods
+Regression Methods
- LaTeX PDF:
@@ -386,6 +360,35 @@ formulas in HTML or ipython notebook files.
+Gradient methods
+
+
+ - LaTeX PDF:
+
+
+ - For printing:
+
+
+
+
+
+ - HTML:
+
+
+
+ - Jupyter notebook:
+
+
+ - ipynb file
+
+
+
+
Logistic Regression
@@ -473,36 +476,7 @@ formulas in HTML or ipython notebook files.
-Elements of Bayesian theory
-
-
- - LaTeX PDF:
-
-
- - For printing:
-
-
-
-
-
- - HTML:
-
-
-
- - Jupyter notebook:
-
-
- - ipynb file
-
-
-
-
-Decision trees, from simple to random ones
+Decision trees, from simple to random ones
- LaTeX PDF:
@@ -531,7 +505,7 @@ formulas in HTML or ipython notebook files.
-Support Vector Machines
+Support Vector Machines
- LaTeX PDF:
@@ -560,7 +534,7 @@ formulas in HTML or ipython notebook files.
-Unsupervised Learning, Boltzmann Machines
+Unsupervised Learning, Boltzmann Machines
- LaTeX PDF:
@@ -589,9 +563,125 @@ formulas in HTML or ipython notebook files.
+Recurrent Neural Networks
+
+
+ - LaTeX PDF:
+
+
+ - For printing:
+
+
+
+
+
+ - HTML:
+
+
+
+ - Jupyter notebook:
+
+
+ - ipynb file
+
+
+
+
+Autoencoders
+
+
+ - LaTeX PDF:
+
+
+ - For printing:
+
+
+
+
+
+ - HTML:
+
+
+
+ - Jupyter notebook:
+
+
+ - ipynb file
+
+
+
+
+Reinforcement Learning
+
+
+ - LaTeX PDF:
+
+
+ - For printing:
+
+
+
+
+
+ - HTML:
+
+
+
+ - Jupyter notebook:
+
+
+ - ipynb file
+
+
+
+
+Elements of Bayesian theory
+
+
+ - LaTeX PDF:
+
+
+ - For printing:
+
+
+
+
+
+ - HTML:
+
+
+
+ - Jupyter notebook:
+
+
+ - ipynb file
+
+
+
+
-Python and Scikit Learn, a short guide
+Python and Scikit Learn, a short guide
- HTML format only:
@@ -604,7 +694,7 @@ formulas in HTML or ipython notebook files.
-Teach yourself C++
+Teach yourself C++
- HTML format only:
@@ -617,9 +707,9 @@ formulas in HTML or ipython notebook files.
-Projects and Exercises Fall 2018
+Projects and Exercises Fall 2018
-First homework set, week 35
+First homework set, week 35
- LaTeX and PDF:
@@ -638,7 +728,7 @@ formulas in HTML or ipython notebook files.
-Second homework set, week 36
+Second homework set, week 36
- LaTeX and PDF:
@@ -657,7 +747,7 @@ formulas in HTML or ipython notebook files.
-Project 1, Deadline October 1
+Project 1, Deadline October 1
- LaTeX and PDF:
@@ -676,7 +766,7 @@ formulas in HTML or ipython notebook files.
-Project 2, Deadline November 5
+Project 2, Deadline November 5
- LaTeX and PDF:
@@ -695,7 +785,7 @@ formulas in HTML or ipython notebook files.
-Project 3, Deadline December 10
+Project 3, Deadline December 10
- LaTeX and PDF:
@@ -714,7 +804,7 @@ formulas in HTML or ipython notebook files.
-Course content
+Course content
Probability theory and statistical methods play a central role in science. Nowadays we are
@@ -733,7 +823,7 @@ tools of probability theory, the aim of this course is to expose you to central
This course covers thus topics like Monte Carlo methods and Markov chains, Bayesian statistics, error estimates, various linear methods, optimization of data and error analysis and central algorithms in machine learning.
The course has several numerical projects and numerical exercises that are meant to illustrate the theory.
-
Learning outcomes
+Learning outcomes
The course introduces a variety of central algorithms and methods
@@ -750,19 +840,19 @@ essential for studies of data analysis and machine learning. The course is proje
- Work on numerical projects to illustrate the theory. The projects play a central role and students are expected to know modern programming languages like Python or C++.
-Prerequisites
+Prerequisites
Basic knowledge in programming and numerics. Required courses are the equivalents to the University of Oslo mathematics courses MAT1100, MAT1110, MAT1120 and at least one of the corresponding computing and programming courses INF1000/INF1110 or MAT-INF1100/MAT-INF1100L/BIOS1100/KJM-INF1xxx.
-
The course has two central parts
+The course has two central parts
- Statistical analysis and optimization of data
- Machine learning
-Statistical analysis and optimization of data
+Statistical analysis and optimization of data
The following topics will be covered
@@ -779,7 +869,7 @@ The following topics will be covered
- Practical optimization using Singular-value decomposition and least squares for parameterizing data.
-Machine learning
+Machine learning
The following topics will be covered
@@ -795,14 +885,14 @@ The following topics will be covered
All the above topics will be supported by examples, hands-on exercises and project work.
-
Recommended textbooks
+Recommended textbooks
- Trevor Hastie, Robert Tibshirani, Jerome H. Friedman, The Elements of Statistical Learning, Springer
- Aurelien Geron, Hands‑On Machine Learning with Scikit‑Learn and TensorFlow, O'Reilly
-Other textbooks
+Other textbooks
General learning book on statistical analysis:
@@ -824,7 +914,7 @@ All the above topics will be supported by examples, hands-on exercises and proje
-
Teaching schedule Fall 2018
+Teaching schedule Fall 2018
Acronyms for textbooks and references to chapter