-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsvm.py
More file actions
24 lines (21 loc) · 679 Bytes
/
svm.py
File metadata and controls
24 lines (21 loc) · 679 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import numpy as np
from sklearn.svm import SVC
import time
import process
start_time = time.time()
print "loading data..."
x_train, y_train, x_test, y_test = process.read_data()
print "training..."
kernel = 'poly'
print "kernel: " + kernel
# 'linear', 'poly', 'rbf', 'sigmoid'
decision_function_shape = 'ovr'
# 'ovr', 'ovo'
print "decision_function_shape: " + decision_function_shape
reg = SVC(kernel=kernel, decision_function_shape=decision_function_shape)
reg.fit(x_train, y_train)
time1 = time.time()
print "--- %s seconds ---" % (time1 - start_time)
print "testing..."
print "accuracy: " + str(reg.score(x_test, y_test))
print "--- %s seconds ---" % (time.time() - time1)