Data Analysis and Machine Learning: Nearest Neighbors and Decision Trees
+
Data Analysis and Machine Learning: Trees, forests and all that
@@ -100,7 +104,7 @@ end of tocinfo -->
[2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University
-
Nov 1, 2018
+
Nov 2, 2018
@@ -128,72 +132,57 @@ continuous but also categorical input and target features.
-
+
+
+
Nodes, leafs, roots and branches
-
Nearest Neighbors
+The main idea of decision trees
+is to find those descriptive features which contain the most
+information regarding the target feature and then split the dataset
+along the values of these features such that the target feature values
+for the resulting sub\_datasets are as pure as possible.
-
-
+The descriptive feature which leaves the target feature most purely is said
+to be the most informative one. This process of finding the most
+informative feature is done until we accomplish a stopping criteria
+where we then finally end up in so called leaf nodes.
-# Generate sample data
-X = np.sort(5*np.random.rand(40,1), axis=0)
-y = X**3
-y=y.ravel()
+
+The leaf nodes
+contain the predictions we will make for new query instances presented
+to our trained model. This is possible since the model has kind of
+learned the underlying structure of the training data and hence can,
+given some assumptions, make predictions about the target feature value
+(class) of unseen query instances.
-# Add noise to targets
-X[::4] +=(0.5- np.random.rand(1))
-y[::5] +=(0.5- np.random.rand(8))
+
+In simplified terms, the process of training a decision tree and
+predicting the target features of query instances is as follows:
+
+
+
Present a dataset containing of a number of training instances characterized by a number of descriptive features and a target feature
+
Train the decision tree model by continuously splitting the target feature along the values of the descriptive features using a measure of information gain during the training process
+
Grow the tree until we accomplish a stopping criteria create leaf nodes which represent the predictions we want to make for new query instances
+
Show query instances to the tree and run down the tree until we arrive at leaf nodes
Data Analysis and Machine Learning: Nearest Neighbors and Decision Trees
+Data Analysis and Machine Learning: Trees, forests and all that
@@ -116,7 +116,7 @@ td.padding {
-
Data Analysis and Machine Learning: Nearest Neighbors and Decision Trees
+
Data Analysis and Machine Learning: Trees, forests and all that
@@ -132,7 +132,7 @@ td.padding {
[2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University
-
Nov 1, 2018
+
Nov 2, 2018
@@ -161,71 +161,56 @@ continuous but also categorical input and target features.
-
Nearest Neighbors
+
Nodes, leafs, roots and branches
+
+The main idea of decision trees
+is to find those descriptive features which contain the most
+information regarding the target feature and then split the dataset
+along the values of these features such that the target feature values
+for the resulting sub\_datasets are as pure as possible.
-
-
+The descriptive feature which leaves the target feature most purely is said
+to be the most informative one. This process of finding the most
+informative feature is done until we accomplish a stopping criteria
+where we then finally end up in so called leaf nodes.
-# Generate sample data
-X = np.sort(5*np.random.rand(40,1), axis=0)
-y = X**3
-y=y.ravel()
+
+The leaf nodes
+contain the predictions we will make for new query instances presented
+to our trained model. This is possible since the model has kind of
+learned the underlying structure of the training data and hence can,
+given some assumptions, make predictions about the target feature value
+(class) of unseen query instances.
-# Add noise to targets
-X[::4] +=(0.5 - np.random.rand(1))
-y[::5] +=(0.5 - np.random.rand(8))
-
-a=np.array(X)
-b=np.array(y)
-
-X_train=a[:19]
-X_test=a[19:]
-y_train=b[:19]
-y_test=b[19:]
-
-model=Pipeline([('poly', PolynomialFeatures(degree=3)),('linear', LinearRegression(fit_intercept=False))])
-model=model.fit(X_train, y_train)
-pred=model.predict(X_test)
-
-
-poly=PolynomialFeatures(degree=3)
-poly.fit_transform(X_train, y_train)
-plt.scatter(X_test, y_test)
-plt.plot(X_test, pred, color='green')
-plt.show()
-
-print (model.score(X_test,y_test))
-
-print ("---------K-Nearest Neighbors-------")
-"""neighbors_settings=range(1,11)
-for n_neighbors in neighbors_settings:
- clf=KNeighborsClassifier(n_neighbors=n_neighbors)
- clf.fit(X_train, y_train)
- training_accuracy.append(clf.score(X_train, y_train))
- test_accuracy.append(clf.score(X_test, y_test))
-
-
-print (mglearn.plots.plot_knn_regression(n_neighbors=3))"""
-
-fromsklearn.neighborsimport KNeighborsRegressor
-
-X, y=mglearn.datasets.make_wave(n_samples=40)
-reg = KNeighborsRegressor(n_neighbors=3)
-reg.fit(X_train, y_train)
-
+
+A decision tree mainly contains of a root node, interior nodes,
+and leaf nodes which are then connected by branches.
-
Decision trees and Regression
+
How do we set it up?
+
+
+In simplified terms, the process of training a decision tree and
+predicting the target features of query instances is as follows:
+
+
+
Present a dataset containing of a number of training instances characterized by a number of descriptive features and a target feature
+
Train the decision tree model by continuously splitting the target feature along the values of the descriptive features using a measure of information gain during the training process
+
Grow the tree until we accomplish a stopping criteria create leaf nodes which represent the predictions we want to make for new query instances
+
Show query instances to the tree and run down the tree until we arrive at leaf nodes
+
+
+
+Then we are essentially done!
+
+
+
+
+
Decision trees and Regression
@@ -318,6 +303,12 @@ plt.title("Decision Tree Regression"
+
+
+
+
+
Maxwell-Boltzmann velocity distribution
+
diff --git a/doc/pub/DecisionTrees/html/DecisionTrees-solarized.html b/doc/pub/DecisionTrees/html/DecisionTrees-solarized.html
index 3bf90a5e3..1c9cc8033 100644
--- a/doc/pub/DecisionTrees/html/DecisionTrees-solarized.html
+++ b/doc/pub/DecisionTrees/html/DecisionTrees-solarized.html
@@ -6,9 +6,9 @@ Automatically generated HTML file from DocOnce source
-
+
-Data Analysis and Machine Learning: Nearest Neighbors and Decision Trees
+Data Analysis and Machine Learning: Trees, forests and all that
@@ -61,8 +61,10 @@ div { text-align: justify; text-justify: inter-word; }
@@ -72,7 +74,7 @@ end of tocinfo -->
-
Data Analysis and Machine Learning: Nearest Neighbors and Decision Trees
+
Data Analysis and Machine Learning: Trees, forests and all that
@@ -88,7 +90,7 @@ end of tocinfo -->
[2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University
-
Nov 1, 2018
+
Nov 2, 2018
@@ -112,72 +114,57 @@ continuous but also categorical input and target features.
-
+
+
+
Nodes, leafs, roots and branches
-
Nearest Neighbors
+The main idea of decision trees
+is to find those descriptive features which contain the most
+information regarding the target feature and then split the dataset
+along the values of these features such that the target feature values
+for the resulting sub\_datasets are as pure as possible.
-
-
+The descriptive feature which leaves the target feature most purely is said
+to be the most informative one. This process of finding the most
+informative feature is done until we accomplish a stopping criteria
+where we then finally end up in so called leaf nodes.
-# Generate sample data
-X = np.sort(5*np.random.rand(40,1), axis=0)
-y = X**3
-y=y.ravel()
+
+The leaf nodes
+contain the predictions we will make for new query instances presented
+to our trained model. This is possible since the model has kind of
+learned the underlying structure of the training data and hence can,
+given some assumptions, make predictions about the target feature value
+(class) of unseen query instances.
-# Add noise to targets
-X[::4] +=(0.5 - np.random.rand(1))
-y[::5] +=(0.5 - np.random.rand(8))
+
+In simplified terms, the process of training a decision tree and
+predicting the target features of query instances is as follows:
+
+
+
Present a dataset containing of a number of training instances characterized by a number of descriptive features and a target feature
+
Train the decision tree model by continuously splitting the target feature along the values of the descriptive features using a measure of information gain during the training process
+
Grow the tree until we accomplish a stopping criteria create leaf nodes which represent the predictions we want to make for new query instances
+
Show query instances to the tree and run down the tree until we arrive at leaf nodes
+
+
+Then we are essentially done!
+
+
+
+
+
Decision trees and Regression
@@ -270,6 +257,11 @@ plt.title("Decision Tree Regression"
+
+
+
+
Maxwell-Boltzmann velocity distribution
+
diff --git a/doc/pub/DecisionTrees/html/DecisionTrees.html b/doc/pub/DecisionTrees/html/DecisionTrees.html
index 9b5a02915..ecadd280b 100644
--- a/doc/pub/DecisionTrees/html/DecisionTrees.html
+++ b/doc/pub/DecisionTrees/html/DecisionTrees.html
@@ -6,9 +6,9 @@ Automatically generated HTML file from DocOnce source
-
+
-Data Analysis and Machine Learning: Nearest Neighbors and Decision Trees
+Data Analysis and Machine Learning: Trees, forests and all that