-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtester.py
More file actions
56 lines (47 loc) · 1.29 KB
/
tester.py
File metadata and controls
56 lines (47 loc) · 1.29 KB
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
import numpy as np
import pprint, re, random, pickle, json, argparse
from datetime import datetime
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans, Birch, DBSCAN
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import classification_report
def test():
# LR = pickle.load(open("./saved/LR.pkl", "rb"))
kmeans = pickle.load(open('kmeans.pkl', 'rb'))
with open("./saved/f.json", "r") as feat:
sf = json.load(feat)
# bots = 0
# for it in sf:
# if str(sf[it][1]) == '1':
# bots += 1
#
# print(bots)
y_true = []
y_pred = []
acc = 0
for i, item in enumerate(sf):
if str(kmeans.predict([ sf[item][0] ])[0]) == str(sf[item][1]):
acc += 1
else:
print(sf[item][0])
y_true.append(str(sf[item][1]))
y_pred.append(str(kmeans.predict([ sf[item][0] ])[0]))
# yt = {}
# for i in y_true:
# if i not in yt:
# yt[i] = 1
# else:
# yt[i] += 1
#
# yp = {}
# for i in y_pred:
# if i not in yp:
# yp[i] = 1
# else:
# yp[i] += 1
#
# print(yt)
# print(yp)
print("Accuracy: " + str((acc*100)/float(len(sf))) + " %")
if __name__ == '__main__':
test()