-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMLR.py
More file actions
26 lines (19 loc) · 698 Bytes
/
MLR.py
File metadata and controls
26 lines (19 loc) · 698 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
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import pickle
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
data = pd.read_csv('taxi.csv')
# print(data.head())
data_x = data.iloc[:,0:-1].values
data_y = data.iloc[:,-1].values
print(data_y)
X_train,X_test,y_train,y_test = train_test_split(data_x,data_y,test_size=0.3,random_state=0)
reg = LinearRegression()
reg.fit(X_train,y_train)
print("Train Score:", reg.score(X_train,y_train))
print("Test Score:", reg.score(X_test,y_test))
pickle.dump(reg, open('taxi.pkl','wb'))
model = pickle.load(open('taxi.pkl','rb'))
print(model.predict([[80, 1770000, 6000, 85]]))