Delete model.py
Browse files
model.py
DELETED
@@ -1,104 +0,0 @@
|
|
1 |
-
import numpy as np
|
2 |
-
import pandas as pd
|
3 |
-
from sklearn.model_selection import train_test_split
|
4 |
-
from sklearn.linear_model import LogisticRegression
|
5 |
-
from sklearn.neighbors import KNeighborsClassifier
|
6 |
-
from sklearn import svm
|
7 |
-
from sklearn.tree import DecisionTreeClassifier
|
8 |
-
from sklearn.ensemble import RandomForestClassifier
|
9 |
-
from sklearn.ensemble import GradientBoostingClassifier
|
10 |
-
from xgboost import XGBClassifier
|
11 |
-
from sklearn.metrics import accuracy_score
|
12 |
-
import joblib
|
13 |
-
import pickle
|
14 |
-
import onnx
|
15 |
-
import random
|
16 |
-
|
17 |
-
|
18 |
-
df=pd.read_csv("Placement (2).csv")
|
19 |
-
df.head()
|
20 |
-
|
21 |
-
df=df.drop(columns=["sl_no","stream","ssc_p","ssc_b","hsc_p","hsc_b","etest_p"])
|
22 |
-
df['internship'] = df['internship'].map({'Yes':random.randint(0,5),'No':0})
|
23 |
-
df['status'] = df['status'].map({'Placed':1,'Not Placed':0})
|
24 |
-
df.head()
|
25 |
-
X_fullstk= df.drop(['status','management','leadership','communication','sales'],axis=1)
|
26 |
-
y= df['status']
|
27 |
-
X_prodengg=df.drop(['status','DSA','java','communication','sales'],axis=1)
|
28 |
-
X_mkt=df.drop(['status','management','leadership','DSA','java'],axis=1)
|
29 |
-
X_train_fullstk,X_test_fullstk,y_train,y_test=train_test_split(X_fullstk,y,test_size=0.20,random_state=42)
|
30 |
-
X_train_prodengg,X_test_prodengg,y_train,y_test=train_test_split(X_prodengg,y,test_size=0.20,random_state=42)
|
31 |
-
X_train_mkt,X_test_mkt,y_train,y_test=train_test_split(X_mkt,y,test_size=0.20,random_state=42)
|
32 |
-
rf_fullstk = RandomForestClassifier()
|
33 |
-
rf_fullstk.fit(X_train_fullstk,y_train)
|
34 |
-
|
35 |
-
rf_prodengg=RandomForestClassifier()
|
36 |
-
rf_prodengg.fit(X_train_prodengg,y_train)
|
37 |
-
|
38 |
-
rf_mkt=RandomForestClassifier()
|
39 |
-
rf_mkt.fit(X_train_mkt,y_train)
|
40 |
-
|
41 |
-
y_pred_full = rf_fullstk.predict(X_test_fullstk)
|
42 |
-
y_pred_prodengg = rf_prodengg.predict(X_test_prodengg)
|
43 |
-
y_pred_mkt = rf_mkt.predict(X_test_mkt)
|
44 |
-
score1=accuracy_score(y_test,y_pred_full)
|
45 |
-
score2=accuracy_score(y_test,y_pred_prodengg)
|
46 |
-
score3=accuracy_score(y_test,y_pred_mkt)
|
47 |
-
rf_fullstk.fit(X_fullstk,y)
|
48 |
-
rf_mkt.fit(X_mkt,y)
|
49 |
-
rf_prodengg.fit(X_prodengg,y)
|
50 |
-
|
51 |
-
new_data_fullstk = pd.DataFrame({
|
52 |
-
'degree_p':75,
|
53 |
-
'internship':1,
|
54 |
-
'DSA':1,
|
55 |
-
'java':0,
|
56 |
-
},index=[0])
|
57 |
-
|
58 |
-
new_data_prodeng = pd.DataFrame({
|
59 |
-
'degree_p':75,
|
60 |
-
'internship':0,
|
61 |
-
'management':1,
|
62 |
-
'leadership':0,
|
63 |
-
},index=[0])
|
64 |
-
|
65 |
-
new_data_mkt = pd.DataFrame({
|
66 |
-
'degree_p':75,
|
67 |
-
'internship':0,
|
68 |
-
'communication':0,
|
69 |
-
'sales':1,
|
70 |
-
},index=[0])
|
71 |
-
|
72 |
-
(rf_fullstk.feature_importances_)
|
73 |
-
(rf_mkt.feature_importances_)
|
74 |
-
|
75 |
-
p_fstk=rf_fullstk.predict(new_data_fullstk)
|
76 |
-
prob_fstk=rf_fullstk.predict_proba(new_data_fullstk)
|
77 |
-
if p_fstk==1:
|
78 |
-
print('Placed')
|
79 |
-
print(f"You will be placed with probability of {prob_fstk[0][1]:.2f}")
|
80 |
-
else:
|
81 |
-
print("Not-placed")
|
82 |
-
|
83 |
-
p_prodeng=rf_prodengg.predict(new_data_prodeng)
|
84 |
-
prob_prdeng=rf_prodengg.predict_proba(new_data_prodeng)
|
85 |
-
if p_prodeng==1:
|
86 |
-
print('Placed')
|
87 |
-
print(f"You will be placed with probability of {prob_prdeng[0][1]:.2f}")
|
88 |
-
else:
|
89 |
-
print("Not-placed")
|
90 |
-
|
91 |
-
p_mkt=rf_mkt.predict(new_data_mkt)
|
92 |
-
prob_mkt=rf_mkt.predict_proba(new_data_mkt)
|
93 |
-
if p_mkt==1:
|
94 |
-
print('Placed')
|
95 |
-
print(f"You will be placed with probability of {prob_mkt[0][1]:.2f}")
|
96 |
-
else:
|
97 |
-
print("Not-placed")
|
98 |
-
|
99 |
-
with open('rf_hacathon_fullstk.pkl', 'wb') as f1:
|
100 |
-
pickle.dump(rf_fullstk, f1)
|
101 |
-
with open('rf_hacathon_prodengg.pkl', 'wb') as f2:
|
102 |
-
pickle.dump(rf_prodengg, f2)
|
103 |
-
with open('rf_hacathon_mkt.pkl', 'wb') as f3:
|
104 |
-
pickle.dump(rf_mkt, f3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|