-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathvalidate_poi.py
55 lines (25 loc) · 909 Bytes
/
validate_poi.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
# coding: utf-8
# In[1]:
import pickle
import sys
from feature_format import featureFormat, targetFeatureSplit
# In[2]:
data_dict = pickle.load(open("C:/Users/Geekquad/ud120-projects/final_project/final_project_dataset_modified_unix.pkl", "rb"))
# In[3]:
features_list = ["poi", "salary"]
# In[5]:
data = featureFormat(data_dict, features_list)
labels, features = targetFeatureSplit(data)
# In[7]:
import sklearn
from sklearn.cross_validation import train_test_split
from sklearn import svm
# In[16]:
features_train, features_test, labels_train, labels_test = train_test_split(features, labels, test_size = 0.3, random_state=42)
# In[17]:
from sklearn.model_selection import GridSearchCV
parameters = {'kernel': ('linear', 'rbf'), 'C': [1, 10]}
svr = svm.SVC()
clf = GridSearchCV(svr, parameters)
clf.fit(features_train,labels_train)
print(clf.score(features_test, labels_test))