-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHW3.py
More file actions
39 lines (18 loc) · 709 Bytes
/
HW3.py
File metadata and controls
39 lines (18 loc) · 709 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from Perceptron.Perceptron import perceptron, test
import numpy as np
training = "Perceptron/bank-note/train.csv"
testing = "Perceptron/bank-note/test.csv"
weights = perceptron(training, 10)
print("vector=", weights[-1][0])
standardresult = test(weights, testing, "standard")
print("standard", standardresult)
votedresult = test(weights, testing, "voted")
for i in range(1, len(weights)):
print(i, ":", weights[i][0], "Correctness:", weights[i][1])
print("voted", votedresult)
averageresult = test(weights, testing, "average")
average = np.zeros(len(weights[1][0]))
for predictor in weights:
average += predictor[0]
print("average vector", average)
print("average", averageresult)