Machine Learning : Part 3 : Decision Tree
We were learn all the stuff regrading the Machine learning .
For Video Lecture on Machine Learning : Decision Go at bottom or google codewithnilesh.
Actually The decision Tress is normal Tree data Structure . we they having Root , Leaf and Internal . You get all idea of Decision Tree By just Viewing below image .
Image made By Garry Raut :
As You Get Idea from This Figure that Decision tree is actually a tree Data Structure .Where if The value is true then go toward the yes i.e. Right Tree .When the condition false or the value is not stratified then go Toward the Left tree.
The Equation for Decision tree is :
Entropy = Σ - p * log(p)
Now we are making model for Prediction of salaries .
Step 1 : Data Preprocessing :
Initially Import all Libraries like Pandas , numpy , matlibplot pyplot & Sklearn
using the pandas take data and classify in to dependent and independent variable.
Code : Garry Raut ( Machine learner )
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
dataset = pd.read_csv('position_salaries.csv')
X = dataset.iloc[: , 1:2].values
Y = dataset.iloc[: ,2].values
Position Level Salary
BusinessAnalyst 1 45232
JuniorConsultant 2 52300
Senior Consultant 3 62300
Manager 4 84300
Country Manager 5 110540
Region Manager 6 160000
Partner 7 250000
Senior Partner 8 341231
C-level 9 670000
CEO 10 3000000
Step :2 : Decision tree regressor
Firstly import the Decision tree regressor class from Sklearn libraries of sub libraries Tree ( Sklearn.tree ) . The class which we import from this libraries is DecisionTreeRegressor . TO access the class the create the regressor object which access the class . now fit the data in regressor object using the fit inbuilt method of machine learning .
Code : Garry Raut ( Machine learner )
from sklearn.tree import DecisionTreeRegressor
regressor= DecisionTreeRegressor(random_state=0)
regressor.fit(X ,Y)
Step 3 : Visualiztion of the data in Graphical view
To View data in Graphical manner we used the Matlibplot librarie.
Code : Garry Raut ( Machine learner )
def desion():
X_grid = np.arange(min(X), max(X), 0.1)
X_grid = X_grid.reshape((len(X_grid), 1))
plt.scatter(X, Y, color = 'green')
plt.plot(X_grid, regressor.predict(X_grid), color = 'blue')
plt.title('Truth or Bluff (Support Vector Regression Model)CodewithNilesh')
plt.xlabel('Position levelCodewithNilesh')
plt.ylabel('SalaryCodewithNilesh')
plt.show()
desion()
We call the method and Show the graphs ou see the below results :
Bookmark This Site for more Update and Share to your friend and many more .....
For Video Lecture on Machine Learning : Decision Tree here
machine learning decision tree example?,machine learning decision tree algorithm?.machine learning decision tree python?,machine learning decision tree example python?,machine learning decision tree regression?,machine learning decision tree ppt?,machine learning decision tree entropy?machine learning decision tree in matlab?,machine learning decision tree?,machine learning decision tree example?,machine learning decision tree algorithm?,machine learning decision tree python?,machine learning decision tree example python?,machine learning decision tree regression?,machine learning decision tree ppt?,
Comments
Post a Comment