-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathtest_classification.py
More file actions
40 lines (37 loc) · 942 Bytes
/
test_classification.py
File metadata and controls
40 lines (37 loc) · 942 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
40
import unittest
from allalgorithms.classification import nearest_neighbor
class TesteClassifications(unittest.TestCase):
def test_nn(self):
#datas
#the first data is Weight and second is number of wheels
features = [
[110,2],
[125,2],
[100,2],
[110,2],
[300,4],
[278,4],
[290,4],
[260,4],
]
#labels, the labels is classification of features line
#in this exemple 0 = Motorcicler, 1 = car
label = [
0,
0,
0,
0,
1,
1,
1,
1,
]
#instance classifier
clf = nearest_neighbor.NN()
#treaning
clf = clf.fit(features,label)
#predict
rs = clf.predict([[2,115]])
self.assertEqual(rs,0)
if __name__ == "__main__":
unittest.main()