-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.py
More file actions
56 lines (41 loc) · 1.3 KB
/
testing.py
File metadata and controls
56 lines (41 loc) · 1.3 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
from random import randint
import copy
from torch.autograd import Variable
import torch
import json
model = torch.load("home_model")
with open("aplist.json") as ap_file:
aplist = json.load(ap_file)
with open("zonelist.json") as zone_file:
zonelist = json.load(zone_file)
with open("raw_dataset.json") as dataset_file:
dataset = json.load(dataset_file)
#test_sample = dataset[30]
with open("scan.json") as scan_file:
test_data = json.load(scan_file)
total = [0] * len(zonelist)
test_input = [None] * len(aplist) * 2
for sample in test_data:
for i in range(len(aplist)):
test_input[i] = -100
test_input[i + len(aplist)] = -100
# For each scan sample in scan
for j in range(len(sample)):
if sample[j]['mac'] == aplist[i]:
test_input[i] = 100
test_input[i + len(aplist)] = int(sample[j]['signal_level_dBm'])
if test_input[i + len(aplist)] > 0:
test_input[i + len(aplist)] == -100
estimation = model(Variable(torch.Tensor([test_input]))).data[0]
selected = 0
for i in range(len(estimation)):
if estimation[i] > estimation[selected]:
selected = i
print estimation
print "\tZone: " + str(zonelist[selected])
total[selected] = total[selected] + 1
selected = 0
for i in range(len(total)):
if total[i] > total[selected]:
selected = i
print "Result: " + str(zonelist[selected])