-
Notifications
You must be signed in to change notification settings - Fork 0
/
LR_Model.py
92 lines (38 loc) · 1020 Bytes
/
LR_Model.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python
# coding: utf-8
# In[16]:
import numpy as np
import pandas as pd
import pickle
# In[17]:
data = pd.read_csv("E:\\Build and Deploy ML\\Deploy in Flask\\Consumer1.csv")
# In[18]:
data.shape
# In[19]:
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
data_scaled = scaler.fit_transform(data)
df = pd.DataFrame.from_records(data_scaled)
# In[20]:
X = df.iloc[:,:2]
# In[21]:
Y= df.iloc[:,-1]
# In[22]:
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error , r2_score
lr_model = LinearRegression()
lr_model.fit(X, Y)
# In[11]:
#Y_predict = lr_model.predict(X)
# In[12]:
#rmse = (np.sqrt(mean_squared_error(Y, Y_predict)))
# In[13]:
#r2 = r2_score(Y, Y_predict)
# In[14]:
#print('RMSE is {}'.format(rmse))
#print('R2 score is {}'.format(r2))
#print("\n")
# In[23]:
# Saving model to disk
pickle.dump(lr_model, open('E:\\Build and Deploy ML\\Deploy in Flask\\model.pkl','wb'))
# In[ ]: