This repository has been archived by the owner on Sep 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
70 lines (60 loc) · 2.6 KB
/
run.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
import perceptron
import fisher
import time
if __name__ == '__main__':
fisher_train = 1000
print("-----------------------------------------------")
print("Running Fisher Linear Discriminant...")
print("Dataset 1...")
start = time.time()
f = fisher.Fisher("datasets\dataset_1.csv", fisher_train)
print("Number of training points: {}".format(fisher_train))
print("Time taken: {}".format(time.time() - start))
print("W vector: {}".format(f.w))
print("Threshold value for Dataset 1 is: {}".format(float(f.threshold)))
print("Number of misclassified points: {}".format(len(f.misclassified)))
print()
print("Dataset 2...")
start = time.time()
f = fisher.Fisher("datasets\dataset_2.csv", fisher_train)
print("Number of training points: {}".format(fisher_train))
print("Time taken: {}".format(time.time() - start))
print("W vector: {}".format(f.w))
print("Threshold value for Dataset 1 is: {}".format(float(f.threshold)))
print("Number of misclassified points: {}".format(len(f.misclassified)))
print()
print("Dataset 3...")
start = time.time()
f = fisher.Fisher("datasets\dataset_3.csv", fisher_train)
print("Number of training points: {}".format(fisher_train))
print("Time taken: {}".format(time.time() - start))
print("W vector: {}".format(f.w))
print("Threshold value for Dataset 1 is: {}".format(float(f.threshold)))
print("Number of misclassified points: {}".format(len(f.misclassified)))
print()
learning_param = 0.1
iterations = 1000
percetron_train = 700
print("-----------------------------------------------")
print("Running Perceptron...")
print("Dataset 1...")
start = time.time()
p = perceptron.Perceptron("datasets\dataset_1.csv", learning_param, iterations, percetron_train)
print("Time Taken: {}".format(time.time() - start))
print("W vector: {}".format(p.w))
print("Number of misclassified points: {}".format(len(p.misclassified)))
print()
print("Dataset 2...")
start = time.time()
p = perceptron.Perceptron("datasets\dataset_2.csv", learning_param, iterations)
print("Time Taken: {}".format(time.time() - start))
print("W vector: {}".format(p.w))
print("Number of misclassified points: {}".format(len(p.misclassified)))
print()
print("Dataset 3...")
start = time.time()
p = perceptron.Perceptron("datasets\dataset_3.csv", learning_param, iterations)
print("Time Taken: {}".format(time.time() - start))
print("W vector: {}".format(p.w))
print("Number of misclassified points: {}".format(len(p.misclassified)))
print()