50471e835b
nothing about random forests
558 lines
26 KiB
HTML
558 lines
26 KiB
HTML
\
|
|
<!DOCTYPE html>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="generator" content="DocOnce: https://github.com/hplgit/doconce/" />
|
|
<meta name="description" content="Data Analysis and Machine Learning: Trees, forests and all that">
|
|
|
|
<title>Data Analysis and Machine Learning: Trees, forests and all that</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- reveal.js: http://lab.hakim.se/reveal-js/ -->
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
|
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
|
|
|
|
<link rel="stylesheet" href="reveal.js/css/reveal.css">
|
|
<link rel="stylesheet" href="reveal.js/css/theme/beige.css" id="theme">
|
|
<!--
|
|
<link rel="stylesheet" href="reveal.js/css/reveal.css">
|
|
<link rel="stylesheet" href="reveal.js/css/theme/beige.css" id="theme">
|
|
<link rel="stylesheet" href="reveal.js/css/theme/beigesmall.css" id="theme">
|
|
<link rel="stylesheet" href="reveal.js/css/theme/solarized.css" id="theme">
|
|
<link rel="stylesheet" href="reveal.js/css/theme/serif.css" id="theme">
|
|
<link rel="stylesheet" href="reveal.js/css/theme/night.css" id="theme">
|
|
<link rel="stylesheet" href="reveal.js/css/theme/moon.css" id="theme">
|
|
<link rel="stylesheet" href="reveal.js/css/theme/simple.css" id="theme">
|
|
<link rel="stylesheet" href="reveal.js/css/theme/sky.css" id="theme">
|
|
<link rel="stylesheet" href="reveal.js/css/theme/darkgray.css" id="theme">
|
|
<link rel="stylesheet" href="reveal.js/css/theme/default.css" id="theme">
|
|
<link rel="stylesheet" href="reveal.js/css/theme/cbc.css" id="theme">
|
|
<link rel="stylesheet" href="reveal.js/css/theme/simula.css" id="theme">
|
|
<link rel="stylesheet" href="reveal.js/css/theme/black.css" id="theme">
|
|
<link rel="stylesheet" href="reveal.js/css/theme/white.css" id="theme">
|
|
<link rel="stylesheet" href="reveal.js/css/theme/league.css" id="theme">
|
|
-->
|
|
|
|
<!-- For syntax highlighting -->
|
|
<link rel="stylesheet" href="reveal.js/lib/css/zenburn.css">
|
|
|
|
<!-- Printing and PDF exports -->
|
|
<script>
|
|
var link = document.createElement( 'link' );
|
|
link.rel = 'stylesheet';
|
|
link.type = 'text/css';
|
|
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
|
|
document.getElementsByTagName( 'head' )[0].appendChild( link );
|
|
</script>
|
|
|
|
<style type="text/css">
|
|
hr { border: 0; width: 80%; border-bottom: 1px solid #aaa}
|
|
p.caption { width: 80%; font-size: 60%; font-style: italic; text-align: left; }
|
|
hr.figure { border: 0; width: 80%; border-bottom: 1px solid #aaa}
|
|
.reveal .alert-text-small { font-size: 80%; }
|
|
.reveal .alert-text-large { font-size: 130%; }
|
|
.reveal .alert-text-normal { font-size: 90%; }
|
|
.reveal .alert {
|
|
padding:8px 35px 8px 14px; margin-bottom:18px;
|
|
text-shadow:0 1px 0 rgba(255,255,255,0.5);
|
|
border:5px solid #bababa;
|
|
-webkit-border-radius: 14px; -moz-border-radius: 14px;
|
|
border-radius:14px;
|
|
background-position: 10px 10px;
|
|
background-repeat: no-repeat;
|
|
background-size: 38px;
|
|
padding-left: 30px; /* 55px; if icon */
|
|
}
|
|
.reveal .alert-block {padding-top:14px; padding-bottom:14px}
|
|
.reveal .alert-block > p, .alert-block > ul {margin-bottom:1em}
|
|
/*.reveal .alert li {margin-top: 1em}*/
|
|
.reveal .alert-block p+p {margin-top:5px}
|
|
/*.reveal .alert-notice { background-image: url(http://hplgit.github.io/doconce/bundled/html_images/small_gray_notice.png); }
|
|
.reveal .alert-summary { background-image:url(http://hplgit.github.io/doconce/bundled/html_images/small_gray_summary.png); }
|
|
.reveal .alert-warning { background-image: url(http://hplgit.github.io/doconce/bundled/html_images/small_gray_warning.png); }
|
|
.reveal .alert-question {background-image:url(http://hplgit.github.io/doconce/bundled/html_images/small_gray_question.png); } */
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<!-- Styles for table layout of slides -->
|
|
<style type="text/css">
|
|
td.padding {
|
|
padding-top:20px;
|
|
padding-bottom:20px;
|
|
padding-right:50px;
|
|
padding-left:50px;
|
|
}
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
<div class="reveal">
|
|
|
|
<!-- Any section element inside the <div class="slides"> container
|
|
is displayed as a slide -->
|
|
|
|
<div class="slides">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<section>
|
|
<!-- ------------------- main content ---------------------- -->
|
|
|
|
|
|
|
|
<center><h1 style="text-align: center;">Data Analysis and Machine Learning: Trees, forests and all that</h1></center> <!-- document title -->
|
|
|
|
<p>
|
|
<!-- author(s): Morten Hjorth-Jensen -->
|
|
|
|
<center>
|
|
<b>Morten Hjorth-Jensen</b> [1, 2]
|
|
</center>
|
|
|
|
<p> <br>
|
|
<!-- institution(s) -->
|
|
|
|
<center>[1] <b>Department of Physics, University of Oslo</b></center>
|
|
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
|
<br>
|
|
<p> <br>
|
|
<center><h4>Nov 2, 2018</h4></center> <!-- date -->
|
|
<br>
|
|
<p>
|
|
|
|
<center style="font-size:80%">
|
|
<!-- copyright --> © 1999-2018, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
|
|
</center>
|
|
</section>
|
|
|
|
|
|
<section>
|
|
<h2 id="___sec0">Decision trees, overarching aims </h2>
|
|
<div class="alert alert-block alert-block alert-text-normal">
|
|
<b></b>
|
|
<p>
|
|
Decision trees are supervised learning algorithms used for both,
|
|
classification and regression tasks where we will concentrate on
|
|
classification in this first part of our decision tree tutorial.
|
|
Decision trees are assigned to the information based learning
|
|
algorithms which use different measures of information gain for
|
|
learning. We can use decision trees for issues where we have
|
|
continuous but also categorical input and target features.
|
|
|
|
|
|
</div>
|
|
</section>
|
|
|
|
|
|
<section>
|
|
<h2 id="___sec1">Nodes, leafs, roots and branches </h2>
|
|
|
|
<p>
|
|
The main idea of decision trees
|
|
is to find those descriptive features which contain the most
|
|
<b>information</b> 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.
|
|
|
|
<p>
|
|
The descriptive feature which leaves the target feature most purely is said
|
|
to be the most informative one. This process of finding the <b>most
|
|
informative</b> feature is done until we accomplish a stopping criteria
|
|
where we then finally end up in so called <b>leaf nodes</b>.
|
|
|
|
<p>
|
|
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.
|
|
|
|
<p>
|
|
A decision tree mainly contains of a <b>root node</b>, <b>interior nodes</b>,
|
|
and <b>leaf nodes</b> which are then connected by <b>branches</b>.
|
|
</section>
|
|
|
|
|
|
<section>
|
|
<h2 id="___sec2">How do we set it up? </h2>
|
|
|
|
<p>
|
|
In simplified terms, the process of training a decision tree and
|
|
predicting the target features of query instances is as follows:
|
|
|
|
<ol>
|
|
<p><li> Present a dataset containing of a number of training instances characterized by a number of descriptive features and a target feature</li>
|
|
<p><li> 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</li>
|
|
<p><li> Grow the tree until we accomplish a stopping criteria create leaf nodes which represent the <em>predictions</em> we want to make for new query instances</li>
|
|
<p><li> Show query instances to the tree and run down the tree until we arrive at leaf nodes</li>
|
|
</ol>
|
|
<p>
|
|
|
|
Then we are essentially done!
|
|
</section>
|
|
|
|
|
|
<section>
|
|
<h2 id="___sec3">Decision trees and Regression </h2>
|
|
<p>
|
|
|
|
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
|
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">numpy</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">np</span>
|
|
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">matplotlib.pyplot</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">plt</span>
|
|
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.preprocessing</span> <span style="color: #8B008B; font-weight: bold">import</span> PolynomialFeatures
|
|
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.linear_model</span> <span style="color: #8B008B; font-weight: bold">import</span> LinearRegression
|
|
|
|
steps=<span style="color: #B452CD">250</span>
|
|
|
|
distance=<span style="color: #B452CD">0</span>
|
|
x=<span style="color: #B452CD">0</span>
|
|
distance_list=[]
|
|
steps_list=[]
|
|
<span style="color: #8B008B; font-weight: bold">while</span> x<steps:
|
|
distance+=np.random.randint(-<span style="color: #B452CD">1</span>,<span style="color: #B452CD">2</span>)
|
|
distance_list.append(distance)
|
|
x+=<span style="color: #B452CD">1</span>
|
|
steps_list.append(x)
|
|
plt.plot(steps_list,distance_list, color=<span style="color: #CD5555">'green'</span>, label=<span style="color: #CD5555">"Random Walk Data"</span>)
|
|
|
|
steps_list=np.asarray(steps_list)
|
|
distance_list=np.asarray(distance_list)
|
|
|
|
X=steps_list[:,np.newaxis]
|
|
|
|
<span style="color: #228B22">#Polynomial fits</span>
|
|
|
|
<span style="color: #228B22">#Degree 2</span>
|
|
poly_features=PolynomialFeatures(degree=<span style="color: #B452CD">2</span>, include_bias=<span style="color: #658b00">False</span>)
|
|
X_poly=poly_features.fit_transform(X)
|
|
|
|
lin_reg=LinearRegression()
|
|
poly_fit=lin_reg.fit(X_poly,distance_list)
|
|
b=lin_reg.coef_
|
|
c=lin_reg.intercept_
|
|
<span style="color: #8B008B; font-weight: bold">print</span> (<span style="color: #CD5555">"2nd degree coefficients:"</span>)
|
|
<span style="color: #8B008B; font-weight: bold">print</span> (<span style="color: #CD5555">"zero power: "</span>,c)
|
|
<span style="color: #8B008B; font-weight: bold">print</span> (<span style="color: #CD5555">"first power: "</span>, b[<span style="color: #B452CD">0</span>])
|
|
<span style="color: #8B008B; font-weight: bold">print</span> (<span style="color: #CD5555">"second power: "</span>,b[<span style="color: #B452CD">1</span>])
|
|
|
|
z = np.arange(<span style="color: #B452CD">0</span>, steps, .<span style="color: #B452CD">01</span>)
|
|
z_mod=b[<span style="color: #B452CD">1</span>]*z**<span style="color: #B452CD">2</span>+b[<span style="color: #B452CD">0</span>]*z+c
|
|
|
|
fit_mod=b[<span style="color: #B452CD">1</span>]*X**<span style="color: #B452CD">2</span>+b[<span style="color: #B452CD">0</span>]*X+c
|
|
plt.plot(z, z_mod, color=<span style="color: #CD5555">'r'</span>, label=<span style="color: #CD5555">"2nd Degree Fit"</span>)
|
|
plt.title(<span style="color: #CD5555">"Polynomial Regression"</span>)
|
|
|
|
plt.xlabel(<span style="color: #CD5555">"Steps"</span>)
|
|
plt.ylabel(<span style="color: #CD5555">"Distance"</span>)
|
|
|
|
<span style="color: #228B22">#Degree 10</span>
|
|
poly_features10=PolynomialFeatures(degree=<span style="color: #B452CD">10</span>, include_bias=<span style="color: #658b00">False</span>)
|
|
X_poly10=poly_features10.fit_transform(X)
|
|
|
|
poly_fit10=lin_reg.fit(X_poly10,distance_list)
|
|
|
|
y_plot=poly_fit10.predict(X_poly10)
|
|
plt.plot(X, y_plot, color=<span style="color: #CD5555">'black'</span>, label=<span style="color: #CD5555">"10th Degree Fit"</span>)
|
|
|
|
plt.legend()
|
|
plt.show()
|
|
|
|
|
|
<span style="color: #228B22">#Decision Tree Regression</span>
|
|
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.tree</span> <span style="color: #8B008B; font-weight: bold">import</span> DecisionTreeRegressor
|
|
regr_1=DecisionTreeRegressor(max_depth=<span style="color: #B452CD">2</span>)
|
|
regr_2=DecisionTreeRegressor(max_depth=<span style="color: #B452CD">5</span>)
|
|
regr_3=DecisionTreeRegressor(max_depth=<span style="color: #B452CD">7</span>)
|
|
regr_1.fit(X, distance_list)
|
|
regr_2.fit(X, distance_list)
|
|
regr_3.fit(X, distance_list)
|
|
|
|
X_test = np.arange(<span style="color: #B452CD">0.0</span>, steps, <span style="color: #B452CD">0.01</span>)[:, np.newaxis]
|
|
y_1 = regr_1.predict(X_test)
|
|
y_2 = regr_2.predict(X_test)
|
|
y_3=regr_3.predict(X_test)
|
|
|
|
<span style="color: #228B22"># Plot the results</span>
|
|
plt.figure()
|
|
plt.scatter(X, distance_list, s=<span style="color: #B452CD">2.5</span>, c=<span style="color: #CD5555">"black"</span>, label=<span style="color: #CD5555">"data"</span>)
|
|
plt.plot(X_test, y_1, color=<span style="color: #CD5555">"red"</span>,
|
|
label=<span style="color: #CD5555">"max_depth=2"</span>, linewidth=<span style="color: #B452CD">2</span>)
|
|
plt.plot(X_test, y_2, color=<span style="color: #CD5555">"green"</span>, label=<span style="color: #CD5555">"max_depth=5"</span>, linewidth=<span style="color: #B452CD">2</span>)
|
|
plt.plot(X_test, y_3, color=<span style="color: #CD5555">"m"</span>, label=<span style="color: #CD5555">"max_depth=7"</span>, linewidth=<span style="color: #B452CD">2</span>)
|
|
|
|
plt.xlabel(<span style="color: #CD5555">"Data"</span>)
|
|
plt.ylabel(<span style="color: #CD5555">"Darget"</span>)
|
|
plt.title(<span style="color: #CD5555">"Decision Tree Regression"</span>)
|
|
plt.legend()
|
|
plt.show()
|
|
</pre></div>
|
|
</section>
|
|
|
|
|
|
<section>
|
|
<h2 id="___sec4">Maxwell-Boltzmann velocity distribution </h2>
|
|
|
|
<p>
|
|
|
|
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
|
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%"><span></span><span style="color: #228B22"># Program to test the Metropolis algorithm with one particle at given temp in</span>
|
|
<span style="color: #228B22"># one dimension</span>
|
|
<span style="color: #228B22">#!/usr/bin/env python</span>
|
|
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">numpy</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">np</span>
|
|
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">matplotlib.mlab</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">mlab</span>
|
|
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">matplotlib.pyplot</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">plt</span>
|
|
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">random</span>
|
|
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">math</span> <span style="color: #8B008B; font-weight: bold">import</span> sqrt, exp, log
|
|
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.preprocessing</span> <span style="color: #8B008B; font-weight: bold">import</span> PolynomialFeatures
|
|
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.linear_model</span> <span style="color: #8B008B; font-weight: bold">import</span> LinearRegression
|
|
<span style="color: #228B22"># initialize the rng with a seed</span>
|
|
random.seed()
|
|
<span style="color: #228B22"># Hard coding of input parameters</span>
|
|
MCcycles = <span style="color: #B452CD">100000</span>
|
|
Temperature = <span style="color: #B452CD">2.0</span>
|
|
beta = <span style="color: #B452CD">1.</span>/Temperature
|
|
InitialVelocity = -<span style="color: #B452CD">2.0</span>
|
|
CurrentVelocity = InitialVelocity
|
|
Energy = <span style="color: #B452CD">0.5</span>*InitialVelocity*InitialVelocity
|
|
VelocityRange = <span style="color: #B452CD">10</span>*sqrt(Temperature)
|
|
VelocityStep = <span style="color: #B452CD">2</span>*VelocityRange/<span style="color: #B452CD">10.</span>
|
|
AverageEnergy = Energy
|
|
AverageEnergy2 = Energy*Energy
|
|
VelocityValues = np.zeros(MCcycles)
|
|
<span style="color: #228B22"># The Monte Carlo sampling with Metropolis starts here</span>
|
|
<span style="color: #8B008B; font-weight: bold">for</span> i <span style="color: #8B008B">in</span> <span style="color: #658b00">range</span> (<span style="color: #B452CD">1</span>, MCcycles, <span style="color: #B452CD">1</span>):
|
|
TrialVelocity = CurrentVelocity + (<span style="color: #B452CD">2.0</span>*random.random() - <span style="color: #B452CD">1.0</span>)*VelocityStep
|
|
EnergyChange = <span style="color: #B452CD">0.5</span>*(TrialVelocity*TrialVelocity -CurrentVelocity*CurrentVelocity);
|
|
<span style="color: #8B008B; font-weight: bold">if</span> random.random() <= exp(-beta*EnergyChange):
|
|
CurrentVelocity = TrialVelocity
|
|
Energy += EnergyChange
|
|
VelocityValues[i] = CurrentVelocity
|
|
AverageEnergy += Energy
|
|
AverageEnergy2 += Energy*Energy
|
|
<span style="color: #228B22">#Final averages</span>
|
|
AverageEnergy = AverageEnergy/MCcycles
|
|
AverageEnergy2 = AverageEnergy2/MCcycles
|
|
Variance = AverageEnergy2 - AverageEnergy*AverageEnergy
|
|
<span style="color: #8B008B; font-weight: bold">print</span>(AverageEnergy, Variance)
|
|
n, bins, patches = plt.hist(VelocityValues, <span style="color: #B452CD">400</span>, facecolor=<span style="color: #CD5555">'green'</span>)
|
|
|
|
plt.xlabel(<span style="color: #CD5555">'$v$'</span>)
|
|
plt.ylabel(<span style="color: #CD5555">'Velocity distribution P(v)'</span>)
|
|
plt.title(<span style="color: #CD5555">r'Velocity histogram at $k_BT=2$'</span>)
|
|
plt.axis([-<span style="color: #B452CD">5</span>, <span style="color: #B452CD">5</span>, <span style="color: #B452CD">0</span>, <span style="color: #B452CD">600</span>])
|
|
plt.grid(<span style="color: #658b00">True</span>)
|
|
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">collections</span> <span style="color: #8B008B; font-weight: bold">import</span> Counter
|
|
|
|
<span style="color: #228B22">#print (Counter(VelocityValues))</span>
|
|
|
|
<span style="color: #8B008B; font-weight: bold">print</span> (VelocityValues[:<span style="color: #B452CD">20</span>])
|
|
VelocityValues=<span style="color: #658b00">list</span>(Counter(VelocityValues).keys())
|
|
d=<span style="color: #658b00">list</span>(Counter(VelocityValues).values())
|
|
|
|
VelocityValues=np.asarray(VelocityValues)[:, np.newaxis]
|
|
d=np.asarray(d)
|
|
<span style="color: #8B008B; font-weight: bold">print</span> (VelocityValues.shape, d.shape)
|
|
|
|
plt.scatter(VelocityValues, d)
|
|
plt.show()
|
|
|
|
<span style="color: #228B22">#2nd Degree Polynomial</span>
|
|
poly_feat=PolynomialFeatures(degree=<span style="color: #B452CD">20</span>, include_bias=<span style="color: #658b00">False</span>)
|
|
X_poly=poly_feat.fit_transform(VelocityValues)
|
|
lin_reg=LinearRegression()
|
|
poly_fit=lin_reg.fit(X_poly,d)
|
|
|
|
y_plot=poly_fit.predict(X_poly)
|
|
plt.title(<span style="color: #CD5555">"Polynomial Fit"</span>)
|
|
plt.plot(VelocityValues, y_plot, color=<span style="color: #CD5555">'black'</span>, label=<span style="color: #CD5555">"Fit"</span>)
|
|
plt.show()
|
|
|
|
<span style="color: #228B22">#Decision Trees</span>
|
|
|
|
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.tree</span> <span style="color: #8B008B; font-weight: bold">import</span> DecisionTreeRegressor
|
|
regr_1=DecisionTreeRegressor(max_depth=<span style="color: #B452CD">2</span>)
|
|
regr_2=DecisionTreeRegressor(max_depth=<span style="color: #B452CD">5</span>)
|
|
regr_3=DecisionTreeRegressor(max_depth=<span style="color: #B452CD">7</span>)
|
|
regr_1.fit(VelocityValues, d)
|
|
regr_2.fit(VelocityValues, d)
|
|
regr_3.fit(VelocityValues, d)
|
|
|
|
X_test = np.arange(<span style="color: #B452CD">0.0</span>, MCcycles, <span style="color: #B452CD">0.01</span>)[:, np.newaxis]
|
|
y_1=regr_1.predict(X_test)
|
|
y_2=regr_2.predict(X_test)
|
|
y_3=regr_3.predict(X_test)
|
|
|
|
plt.title(<span style="color: #CD5555">"Decision Tree"</span>)
|
|
plt.plot(X_test, y_1, color=<span style="color: #CD5555">"red"</span>, label=<span style="color: #CD5555">"max_depth=2"</span>, linewidth=<span style="color: #B452CD">2</span>)
|
|
plt.plot(X_test, y_2, color=<span style="color: #CD5555">"green"</span>, label=<span style="color: #CD5555">"max_depth=5"</span>, linewidth=<span style="color: #B452CD">2</span>)
|
|
plt.plot(X_test, y_3, color=<span style="color: #CD5555">"m"</span>, label=<span style="color: #CD5555">"max_depth=7"</span>, linewidth=<span style="color: #B452CD">2</span>)
|
|
plt.show()
|
|
|
|
<span style="color: #228B22">#Separate each frequency not in one specific velocity, but in a range of values,</span>
|
|
<span style="color: #228B22">#i.e. frequency of all velocities in range -5 to -4.9, -4.9 to -4.8, etc...</span>
|
|
</pre></div>
|
|
</section>
|
|
|
|
|
|
|
|
</div> <!-- class="slides" -->
|
|
</div> <!-- class="reveal" -->
|
|
|
|
<script src="reveal.js/lib/js/head.min.js"></script>
|
|
<script src="reveal.js/js/reveal.js"></script>
|
|
|
|
<script>
|
|
// Full list of configuration options available here:
|
|
// https://github.com/hakimel/reveal.js#configuration
|
|
Reveal.initialize({
|
|
|
|
// Display navigation controls in the bottom right corner
|
|
controls: true,
|
|
|
|
// Display progress bar (below the horiz. slider)
|
|
progress: true,
|
|
|
|
// Display the page number of the current slide
|
|
slideNumber: true,
|
|
|
|
// Push each slide change to the browser history
|
|
history: false,
|
|
|
|
// Enable keyboard shortcuts for navigation
|
|
keyboard: true,
|
|
|
|
// Enable the slide overview mode
|
|
overview: true,
|
|
|
|
// Vertical centering of slides
|
|
//center: true,
|
|
center: false,
|
|
|
|
// Enables touch navigation on devices with touch input
|
|
touch: true,
|
|
|
|
// Loop the presentation
|
|
loop: false,
|
|
|
|
// Change the presentation direction to be RTL
|
|
rtl: false,
|
|
|
|
// Turns fragments on and off globally
|
|
fragments: true,
|
|
|
|
// Flags if the presentation is running in an embedded mode,
|
|
// i.e. contained within a limited portion of the screen
|
|
embedded: false,
|
|
|
|
// Number of milliseconds between automatically proceeding to the
|
|
// next slide, disabled when set to 0, this value can be overwritten
|
|
// by using a data-autoslide attribute on your slides
|
|
autoSlide: 0,
|
|
|
|
// Stop auto-sliding after user input
|
|
autoSlideStoppable: true,
|
|
|
|
// Enable slide navigation via mouse wheel
|
|
mouseWheel: false,
|
|
|
|
// Hides the address bar on mobile devices
|
|
hideAddressBar: true,
|
|
|
|
// Opens links in an iframe preview overlay
|
|
previewLinks: false,
|
|
|
|
// Transition style
|
|
transition: 'default', // default/cube/page/concave/zoom/linear/fade/none
|
|
|
|
// Transition speed
|
|
transitionSpeed: 'default', // default/fast/slow
|
|
|
|
// Transition style for full page slide backgrounds
|
|
backgroundTransition: 'default', // default/none/slide/concave/convex/zoom
|
|
|
|
// Number of slides away from the current that are visible
|
|
viewDistance: 3,
|
|
|
|
// Parallax background image
|
|
//parallaxBackgroundImage: '', // e.g. "'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg'"
|
|
|
|
// Parallax background size
|
|
//parallaxBackgroundSize: '' // CSS syntax, e.g. "2100px 900px"
|
|
|
|
theme: Reveal.getQueryHash().theme, // available themes are in reveal.js/css/theme
|
|
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/none
|
|
|
|
});
|
|
|
|
Reveal.initialize({
|
|
dependencies: [
|
|
// Cross-browser shim that fully implements classList - https://github.com/eligrey/classList.js/
|
|
{ src: 'reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
|
|
|
|
// Interpret Markdown in <section> elements
|
|
{ src: 'reveal.js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
|
|
{ src: 'reveal.js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
|
|
|
|
// Syntax highlight for <code> elements
|
|
{ src: 'reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
|
|
|
|
// Zoom in and out with Alt+click
|
|
{ src: 'reveal.js/plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
|
|
|
|
// Speaker notes
|
|
{ src: 'reveal.js/plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } },
|
|
|
|
// Remote control your reveal.js presentation using a touch device
|
|
//{ src: 'reveal.js/plugin/remotes/remotes.js', async: true, condition: function() { return !!document.body.classList; } },
|
|
|
|
// MathJax
|
|
//{ src: 'reveal.js/plugin/math/math.js', async: true }
|
|
]
|
|
});
|
|
|
|
Reveal.initialize({
|
|
|
|
// The "normal" size of the presentation, aspect ratio will be preserved
|
|
// when the presentation is scaled to fit different resolutions. Can be
|
|
// specified using percentage units.
|
|
width: 1170, // original: 960,
|
|
height: 700,
|
|
|
|
// Factor of the display size that should remain empty around the content
|
|
margin: 0.1,
|
|
|
|
// Bounds for smallest/largest possible scale to apply to content
|
|
minScale: 0.2,
|
|
maxScale: 1.0
|
|
|
|
});
|
|
</script>
|
|
|
|
<!-- begin footer logo
|
|
<div style="position: absolute; bottom: 0px; left: 0; margin-left: 0px">
|
|
<img src="somelogo.png">
|
|
</div>
|
|
end footer logo -->
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|