-
Notifications
You must be signed in to change notification settings - Fork 0
/
classifier.py
139 lines (61 loc) · 2.92 KB
/
classifier.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import numpy as np
import pandas as pd
import math
stdata = pd.read_csv(input())
stdata.head()
stdata.drop(['Certifications/Achievement/ Research papers','Link to updated Resume (Google/ One Drive link preferred)','link to Linkedin profile','How Did You Hear About This Internship?'],axis=1,inplace=True)
stdata.drop(['First Name','Last Name','City','State','Zip Code','DOB [DD/MM/YYYY]','Gender','Email Address',
'Contact Number','Emergency Contact Number','College name','University Name',],axis=1,inplace=True)
degree = pd.get_dummies(stdata['Degree'],drop_first = True)
areaofstudy = pd.get_dummies(stdata['Major/Area of Study'])
year = pd.get_dummies(stdata['Which-year are you studying in?'],drop_first = True)
def rating_function(x):
if x == "yes":
return 1
else:
return 0
stdata["java"] = stdata["Have you worked core Java"].apply(rating_function)
lan = pd.get_dummies(stdata['Programming Language Known other than Java (one major)'])
def rating_function(x):
if x == "yes":
return 1
else:
return 0
stdata["sql"] = stdata["Have you worked on MySQL or Oracle database"].apply(rating_function)
def rating_function(x):
if x == "yes":
return 1
else:
return 0
stdata["oops"] = stdata["Have you studied OOP Concepts"].apply(rating_function)
def rating_function(x):
if x == "yes":
return 1
else:
return 0
stdata["py3"] = stdata["Programming Language Known other than Java (one major)"].apply(rating_function)
interest = pd.get_dummies(stdata['Areas of interest'],drop_first=True)
stdata = pd.concat([stdata,degree,areaofstudy,year,lan,interest],axis = 1)
stdata.drop(['Degree','Major/Area of Study', 'Course Type', 'Which-year are you studying in?','Areas of interest','Current Employment Status', 'Have you worked core Java',
'Programming Language Known other than Java (one major)','Have you worked on MySQL or Oracle database',
'Have you studied OOP Concepts','Python'],axis = 1, inplace = True)
select = pd.get_dummies(stdata['Label'],dtype = int)
stdata = pd.concat([stdata,select],axis = 1)
stdata = stdata.drop(['ineligible','Label'],axis = 1)
stdata.head()
X = stdata.drop('eligible',axis = 1)
y = stdata['eligible']
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=1)
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.svm import SVC
clf = make_pipeline(StandardScaler(), SVC(gamma='auto'))
clf.fit(X_train, y_train)
prediction = clf.predict(X_test)
from sklearn.metrics import classification_report
from sklearn.metrics import accuracy_score, confusion_matrix,classification_report
from sklearn.metrics import f1_score
classification_report(y_test,prediction)
f = f1_score(y_test, prediction,average = None)
print("F1 Score ::",f[0])