-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpredictor.py
56 lines (46 loc) · 1.38 KB
/
predictor.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
import pickle
import pandas as pd
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
dataset = pd.read_csv('SRM-CLUB-INWEB.csv')
X = dataset.iloc[:, :-6].values
y = dataset.iloc[:, -1].values
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.9, random_state = 0)
classifier = RandomForestClassifier(n_estimators = 10, criterion = 'entropy', random_state = 0)
classifier.fit(X_train, y_train)
pickle.dump(classifier,open('model.pkl','wb'))
model=pickle.load(open('model.pkl','rb'))
# #!C:\Users\Lenovo\AppData\Local\Programs\Python\Python37-32\python.exe
#
# import numpy as np
# import pandas as pd
# from sklearn.linear_model import LogisticRegression
# from sklearn.model_selection import train_test_split
# import warnings
# import pickle
# warnings.filterwarnings("ignore")
#
# data = pd.read_csv("Forest_fire.csv")
# data = np.array(data)
#
# X = data[1:, 1:-1]
# y = data[1:, -1]
# y = y.astype('int')
# X = X.astype('int')
# # print(X,y)
# X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=0)
# log_reg = LogisticRegression()
#
#
# log_reg.fit(X_train, y_train)
#
# inputt = [int(x) for x in "45 32 60".split(' ')]
# final = [np.array(inputt)]
#
# b = log_reg.predict_proba(final)
#
#
# pickle.dump(log_reg, open('model.pkl','wb'))
# model = pickle.load(open('model.pkl','rb'))
#
#