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.
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.
 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.
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.
A decision tree mainly contains of a root node, interior nodes, and leaf nodes which are then connected by branches.
In simplified terms, the process of training a decision tree and predicting the target features of query instances is as follows:
import numpy as np
import matplotlib.pyplot as plt
from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import LinearRegression
steps=250
distance=0
x=0
distance_list=[]
steps_list=[]
while x<steps:
distance+=np.random.randint(-1,2)
distance_list.append(distance)
x+=1
steps_list.append(x)
plt.plot(steps_list,distance_list, color='green', label="Random Walk Data")
steps_list=np.asarray(steps_list)
distance_list=np.asarray(distance_list)
X=steps_list[:,np.newaxis]
#Polynomial fits
#Degree 2
poly_features=PolynomialFeatures(degree=2, include_bias=False)
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_
print ("2nd degree coefficients:")
print ("zero power: ",c)
print ("first power: ", b[0])
print ("second power: ",b[1])
z = np.arange(0, steps, .01)
z_mod=b[1]*z**2+b[0]*z+c
fit_mod=b[1]*X**2+b[0]*X+c
plt.plot(z, z_mod, color='r', label="2nd Degree Fit")
plt.title("Polynomial Regression")
plt.xlabel("Steps")
plt.ylabel("Distance")
#Degree 10
poly_features10=PolynomialFeatures(degree=10, include_bias=False)
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='black', label="10th Degree Fit")
plt.legend()
plt.show()
#Decision Tree Regression
from sklearn.tree import DecisionTreeRegressor
regr_1=DecisionTreeRegressor(max_depth=2)
regr_2=DecisionTreeRegressor(max_depth=5)
regr_3=DecisionTreeRegressor(max_depth=7)
regr_1.fit(X, distance_list)
regr_2.fit(X, distance_list)
regr_3.fit(X, distance_list)
X_test = np.arange(0.0, steps, 0.01)[:, np.newaxis]
y_1 = regr_1.predict(X_test)
y_2 = regr_2.predict(X_test)
y_3=regr_3.predict(X_test)
# Plot the results
plt.figure()
plt.scatter(X, distance_list, s=2.5, c="black", label="data")
plt.plot(X_test, y_1, color="red",
label="max_depth=2", linewidth=2)
plt.plot(X_test, y_2, color="green", label="max_depth=5", linewidth=2)
plt.plot(X_test, y_3, color="m", label="max_depth=7", linewidth=2)
plt.xlabel("Data")
plt.ylabel("Darget")
plt.title("Decision Tree Regression")
plt.legend()
plt.show()
# Program to test the Metropolis algorithm with one particle at given temp in
# one dimension
#!/usr/bin/env python
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
import random
from math import sqrt, exp, log
from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import LinearRegression
# initialize the rng with a seed
random.seed()
# Hard coding of input parameters
MCcycles = 100000
Temperature = 2.0
beta = 1./Temperature
InitialVelocity = -2.0
CurrentVelocity = InitialVelocity
Energy = 0.5*InitialVelocity*InitialVelocity
VelocityRange = 10*sqrt(Temperature)
VelocityStep = 2*VelocityRange/10.
AverageEnergy = Energy
AverageEnergy2 = Energy*Energy
VelocityValues = np.zeros(MCcycles)
# The Monte Carlo sampling with Metropolis starts here
for i in range (1, MCcycles, 1):
TrialVelocity = CurrentVelocity + (2.0*random.random() - 1.0)*VelocityStep
EnergyChange = 0.5*(TrialVelocity*TrialVelocity -CurrentVelocity*CurrentVelocity);
if random.random() <= exp(-beta*EnergyChange):
CurrentVelocity = TrialVelocity
Energy += EnergyChange
VelocityValues[i] = CurrentVelocity
AverageEnergy += Energy
AverageEnergy2 += Energy*Energy
#Final averages
AverageEnergy = AverageEnergy/MCcycles
AverageEnergy2 = AverageEnergy2/MCcycles
Variance = AverageEnergy2 - AverageEnergy*AverageEnergy
print(AverageEnergy, Variance)
n, bins, patches = plt.hist(VelocityValues, 400, facecolor='green')
plt.xlabel('$v$')
plt.ylabel('Velocity distribution P(v)')
plt.title(r'Velocity histogram at $k_BT=2$')
plt.axis([-5, 5, 0, 600])
plt.grid(True)
from collections import Counter
#print (Counter(VelocityValues))
print (VelocityValues[:20])
VelocityValues=list(Counter(VelocityValues).keys())
d=list(Counter(VelocityValues).values())
VelocityValues=np.asarray(VelocityValues)[:, np.newaxis]
d=np.asarray(d)
print (VelocityValues.shape, d.shape)
plt.scatter(VelocityValues, d)
plt.show()
#2nd Degree Polynomial
poly_feat=PolynomialFeatures(degree=20, include_bias=False)
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("Polynomial Fit")
plt.plot(VelocityValues, y_plot, color='black', label="Fit")
plt.show()
#Decision Trees
from sklearn.tree import DecisionTreeRegressor
regr_1=DecisionTreeRegressor(max_depth=2)
regr_2=DecisionTreeRegressor(max_depth=5)
regr_3=DecisionTreeRegressor(max_depth=7)
regr_1.fit(VelocityValues, d)
regr_2.fit(VelocityValues, d)
regr_3.fit(VelocityValues, d)
X_test = np.arange(0.0, MCcycles, 0.01)[:, 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("Decision Tree")
plt.plot(X_test, y_1, color="red", label="max_depth=2", linewidth=2)
plt.plot(X_test, y_2, color="green", label="max_depth=5", linewidth=2)
plt.plot(X_test, y_3, color="m", label="max_depth=7", linewidth=2)
plt.show()
#Separate each frequency not in one specific velocity, but in a range of values,
#i.e. frequency of all velocities in range -5 to -4.9, -4.9 to -4.8, etc...


-*- html -*- YXA source code documentation @title Config subsystem @doc The configuration subsystem is designed to be extendible if someone wants to add some new backend holding configuration, for example an SQL database, or XML or INI files. Validation is done in yxa_config_check. The main interface to this subsystem is yxa_config. === Backends ===


Minister of HealthAbdulla Nazim Ibrahim Minister of State for HealthDr. Mohamed Habeeb Dr. Aishath Rameela Dr. Abdulla Waheed Deputy Minister of HealthMr. Mohamed Zaheen (Senior Policy Executive) Mohamed Rafeeq Hassan Mohamed Mahir (Senior Policy Excecutive) |
MissionTo ensure nation’s participation in attaining excellence in quality health services, in an affordable, equitable and accessible manner leading to a healthy population VisionTogether as a nation for excellence in health Departments / CouncilsMinistry of Health Health Protection Agency Policy Planning & International Health Division |


Select the three actions on this page in order to illustrate direct read and write activities happening with LOB data.
SELECT DIRECT_READS, DIRECT_WRITES
FROM SYSIBMADM.SNAPDB
SELECT VIEW_TEXT, COLUMN_TEXT
FROM INLINELOBDATA
The third step compares the direct read and write statistics before and after the execution of the query. Please note that there is a 104 direct reads overhead generated by the Technology Explorer. If the same SQL statements run on the DB2 command, you will not see the overhead.


Jay is a proven driver of integrating cloud automation, big data, and predictive analytics into reliable, scalable solutions. He enjoys cloud architecture, data science, driving solution adoption, IT strategy, and people development.


Royal Bank of Canada | Quantitative Researcher and Trader Summer 2020
Rotation 1: Global Equity Algorithmic Trading
Rotation 2: Quantitative Strategy Group
Fidelity Investments | Software Engineering Intern Spring 2019
Last Summer, I worked with the alternative investments team to develop an internal application (C#, ASP.NET) that manages a large database of electronic trades. I added multiple functionalities to the back-end to improve the file transfer pipeline such as compression and validation of trade requirements.
PenPath LLC | Data Engineer Summer 2019
During the spring of my freshman year, I worked on a project with the marketing start-up PenPath LLC to build a model based on supervised regression techniques in python that predicts revenue based on multiple marketing features such as impressions, views, etc. We also created a visualization of the model for the company that can be viewed on a personal dashboard for each of PenPath's clients.
MIT Francis Bitter Laboratory | Research Intern Summer 2017
During the summer of 2017, I worked under professor Jagadeesh Moodera, where I developed and programmed a novel method of modulation doping of Vanadium to improve the Curie temperature in topological insulators. I also worked a little bit on other materials such as superconductors, examining their properties and quantum effects based on the underlying material in sub-4K temperatures. Learn more about my research here


--- layout: api title: "v1.6.0 API: Viewport" categories: api version: v1.6.0 permalink: /api/v1.6.0/viewport ---
Modern mobile browsers now support scaling of webpages by leveraging the meta
tag viewport
. This enlarges the window making your map look better on a
mobile device.


Name: Range Rover
Top Speed: 180km
Seats: 4
Color: White
Price: Ksh 6,500,000
Name: Range Rover
Top Speed: 180km
Seats: 4
Color: Orange
Price: Ksh 6,000,000
Name: Subaru Forester
Top Speed: 180km
Seats: 4
Color: Black
Price: Ksh 1,800,000
Name: Mercedes-Benz GLB 250
Top Speed: 180km
Seats: 4
Color: White
Price: Ksh 5,00,000
Name: BMW X1
Top Speed: 180km
Seats: 4
Color: white
Price: Ksh 1,700,000
Name: BMW X3
Top Speed: 180km
Seats: 4
Color: Blue
Price: Ksh 2,500,000
Name: BMW 6
Top Speed: 180km
Seats: 4
Color: Brown
Price: Ksh 5,500,00
Name: BMW 4
Top Speed: 180km
Seats: 4
Color: Red
Price: Ksh 4,500,00


--- layout: post title: Silence ahoy date: 2008-07-26 00:00:00 categories: aikido personal ---
Things will be quiet here for a little while. I'm now on 2 weeks holiday. Week 1 will be spent in Chester at the BAF Summer School, as is my wont. Week 2 I'm in Brighton recovering...


{% extends '../../layout-email.html' %} {% block pageTitle %} Prior notification email {% endblock %} {% block content %}
Notifications will be removed after 8 weeeks.
View patients that need reviewing
If you currently receive notifications but need to stop them you can manage emails


@(title: String) @main(title) {
This is the Playful Prelaunch Play Framework sample application. You can find a working version of this app at Heroku.