-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest20151112.py
59 lines (51 loc) · 1.56 KB
/
test20151112.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
# Copyright (C) 2015 Rene Pihlak
import numpy as np
from sklearn import svm, metrics
learn_data = [
[1,1,1,1,1],
[1,1,1,0,0],
[1,0,0,0,0],
[0,0,0,0,0],
[1,1,1,1,1],
[0,1,1,1,0],
[0,1,0,0,0],
[0,0,0,0,0],
[1,1,1,1,1],
[0,0,1,1,1],
[0,0,1,0,0],
[0,0,0,0,0],
[1,1,1,1,1],
[1,0,0,1,1],
[0,0,0,1,0],
[0,0,0,0,0],
[1,1,1,1,1],
[1,1,0,0,1],
[0,0,0,0,1],
[0,0,0,0,0]]
learn_labels = [0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3]
learn_labels_names = ["dead", "dying", "ok", "perfect", "dead", "dying", "ok", "perfect", "dead", "dying", "ok", "perfect", "dead", "dying", "ok", "perfect", "dead", "dying", "ok", "perfect"]
print("LEARNING DATA:")
for index in range(0, len(learn_data)):
print("%s: %d :: %s" % (learn_data[index], learn_labels[index], learn_labels_names[index]))
data = [
[1,1,1,1,1],
[1,1,1,0,0],
[1,0,0,0,0],
[0,0,0,0,0],
[1,1,1,1,1],
[1,1,1,0,0],
[1,0,0,1,0],
[0,0,0,0,1],
[0,1,0,0,0],
[0,0,1,0,0],
[1,0,1,1,0],
[1,1,0,1,1],
[0,0,1,1,1]]
# Create a classifier: a support vector classifier
classifier = svm.SVC(gamma=0.001)
# We learn the digits on the first half of the digits
classifier.fit(learn_data, learn_labels)
predicted = classifier.predict(data)
print("ANALYSED DATA:")
for index in range(0, len(data)):
print("%s: %s" % (data[index], learn_labels_names[predicted[index]]))