-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel.py
More file actions
60 lines (42 loc) · 1.5 KB
/
Copy pathmodel.py
File metadata and controls
60 lines (42 loc) · 1.5 KB
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
import numpy as np
import pandas as pd
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
import pickle
import requests
import json
wine_data = pd.read_csv('WineQT.csv')
X = wine_data.drop(columns=['quality'])
y = wine_data['quality']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = .33, random_state = 0)
model = RandomForestClassifier()
model.fit(X, y)
predictions = model.predict([ [7, .3, 0, 1.5, .05, 15, 30, .99, 3.5, .75, 14] ])
y_pred = model.predict(X_test)
pickle.dump(model, open('model.pkl','wb'))
model = pickle.load(open('model.pkl','rb'))
#print(model.predict([ [7,.3,0,1.5,.05,15,30,.99,3.5,.75,14, 0] ]))
#Linear Regression
'''
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import pickle
import requests
import json
wine_data = pd.read_csv('WineQT.csv')
correct_features = wine_data.drop(columns=['Id',])
X = correct_features.iloc[:,:-1].values
#X = wine_data.iloc[:, :-1].values
y = wine_data.iloc[:, 1].values
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=.33, random_state = 0 )
from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(X_train, y_train)
y_pred = regressor.predict(X_test)
pickle.dump(regressor, open('model.pkl','wb'))
model = pickle.load(open('model.pkl','rb'))
print(model.predict([ [7,.3,0,1.5,.05,15,30,.99,3.5,.75,14, 0] ]))
'''