Skip to content
This repository has been archived by the owner on Oct 23, 2018. It is now read-only.

Commit

Permalink
Merge pull request #10 from amanparmar17/four
Browse files Browse the repository at this point in the history
script for decision tree regressor
  • Loading branch information
amanparmar17 authored Oct 15, 2018
2 parents c28d662 + 34416d3 commit 6dfe971
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Python/dec_tree_reg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pandas as pa
import numpy as np
import matplotlib.pyplot as plt

datset=pa.read_csv("Position_Salaries.csv")
x= datset.ix[:,1:2].values
y= datset.ix[:,-1].values

#%%
from sklearn.tree import DecisionTreeRegressor
regressor=DecisionTreeRegressor(random_state=0)
regressor.fit(x,y)
#%% final prediction using model
ypred=regressor.predict(6.5)
print(ypred)
#%%
#visualisation
xgrid=np.arange(min(x),max(x),0.01)
xgrid=xgrid.reshape(len(xgrid),1)

plt.scatter(x,y,color="red")
plt.plot(xgrid,regressor.predict((xgrid)),color="orange")
plt.xlabel("values")
plt.ylabel("predicted linear")
plt.title("linear")
plt.show()

0 comments on commit 6dfe971

Please sign in to comment.