diff --git a/doc/pub/DecisionTrees/html/DecisionTrees-bs.html b/doc/pub/DecisionTrees/html/DecisionTrees-bs.html index 1f17cb1bd..4c899ab8f 100644 --- a/doc/pub/DecisionTrees/html/DecisionTrees-bs.html +++ b/doc/pub/DecisionTrees/html/DecisionTrees-bs.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 @@ -41,8 +41,10 @@ Automatically generated HTML file from DocOnce source @@ -56,7 +58,7 @@ end of tocinfo --> - Data Analysis and Machine Learning: Nearest Neighbors and Decision Trees + Data Analysis and Machine Learning: Trees, forests and all that + + + +
+

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. - -

import mglearn
-import numpy as np
-from sklearn import linear_model
-from sklearn.linear_model import LinearRegression
-import matplotlib.pyplot as plt
-from sklearn.preprocessing import PolynomialFeatures
-from sklearn.pipeline import Pipeline
-from sklearn.neighbors import KNeighborsClassifier
+

+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 decision tree mainly contains of a root node, interior nodes, +and leaf nodes which are then connected by branches. -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))""" - -from sklearn.neighbors import KNeighborsRegressor - -X, y=mglearn.datasets.make_wave(n_samples=40) -reg = KNeighborsRegressor(n_neighbors=3) -reg.fit(X_train, y_train) -











-

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: + +

    +
  1. Present a dataset containing of a number of training instances characterized by a number of descriptive features and a target feature
  2. +
  3. 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
  4. +
  5. Grow the tree until we accomplish a stopping criteria create leaf nodes which represent the predictions we want to make for new query instances
  6. +
  7. Show query instances to the tree and run down the tree until we arrive at leaf nodes
  8. +
+ +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