-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregrTree.py
More file actions
40 lines (29 loc) · 857 Bytes
/
regrTree.py
File metadata and controls
40 lines (29 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 15 22:52:30 2017
@author: Khagendra
"""
from numba import jit
@jit
def regr(X_train,Y_train,X,Y):
from sklearn.tree import DecisionTreeRegressor
regressor=DecisionTreeRegressor(criterion="mae",random_state=0)
regressor.fit(X_train,Y_train)
pred=[]
for i in range(9,38):
k=int(input("Entries to be the values to be predicted:"))
pred.append(k)
Y_pred=regressor.predict(pred)
print("Future possible value:"+Y_pred)
return Y_pred
#plot
""" Plotting the graph"""
import matplotlib.pyplot as plt
plt.scatter(X,Y,color="red")
plt.plot(X,regressor.predict(X),color="blue")
plt.title('Mortality Rate Graph')
plt.show()
"""Saving the model"""
import pickle
s=pickle.dumps(regressor)
return s