Machine Learning :Part 4: Random Forest Regression ( Last Regression model )
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
In Forest Tree model the NO of Decision tree is directly propositional to the accuracy of prediction.
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)
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
After this go to the Secound Step
Step 2 : Random Forest Regression
this is simple code for calling random forest Regressor.
from sklearn.ensemble import RandomForestRegression
regressor = RandomForestRegression(n_estimator=10)regressor.fit(X,Y)
Full Source Code
:
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
from sklearn.ensemble import RandomForestRegressor
regressor = RandomForestRegressor()
regressor.fit(X,Y)
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()
Result :
For Video Lecture on Machine Learning : Random Forest Regression ( Tree )
machine learning random forest regression ? ,random forest regression machine learning mastery? ,
Comments
Post a Comment