This repository was archived by the owner on Mar 28, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdriver.py
44 lines (31 loc) · 1.47 KB
/
driver.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
# Author Alvaro Esperanca
from SVM import SVM
from PreProcessor import PreProcessor
from Validator import Validator
from GaussianKernel import GaussianKernel
import numpy as np
if __name__ == "__main__":
pre = PreProcessor()
val = Validator()
clf = SVM(kernel=GaussianKernel(5.0), C=1.0)
X_train, y_train = pre.loadTrainingSet("training_data/Cancer_Sample_Tokenized.csv")
X_test = pre.loadTestSet("test_data/Tokenized_Cancer_test.csv")
clf.fit(X_train, y_train)
predictions = clf.predict(X_test)
validFile = open("validation_set/validation_set_labels.txt", "r")
temp = validFile.readlines()
validationLabels = [float(num) for num in temp]
val.validate(validationLabels, predictions)
val.report()
# predFile = open("results/gaussian_kernel_s_5000_c_5.txt", "w")
# statFile = open("results/gaussian_kernel_s_5000_c_5_stats.txt", "w")
# for prediction in predictions:
# predFile.write("%d\n" % prediction)
# statFile.write("%-20s %-5d\n" % ("True Positives:", val.truePositives()) )
# statFile.write("%-20s %-5d\n" % ("True Negatives:", val.trueNegatives()) )
# statFile.write("%-20s %-5d\n" % ("False Positives:", val.falsePositives()) )
# statFile.write("%-20s %-5d\n\n" % ("False Negatives:", val.falseNegatives()) )
# statFile.write("%-20s %.2f\n" % ("Accuracy:", val.precision()) )
# statFile.write("%-20s %.2f\n" % ("Recall:", val.recall()) )
# predFile.close()
# statFile.close()