-
Notifications
You must be signed in to change notification settings - Fork 0
/
efficiency-test.html
57 lines (48 loc) · 1.45 KB
/
efficiency-test.html
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
<html>
<head>
<title></title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script type="text/javascript" src="advanced-geocoder.js"></script>
<script type="text/javascript" src="Data/testSet.js"></script>
</head>
<body>
<script type="text/javascript">
var property = "SubDist_NE";
var geocoder;
d3.json("Data/Admin3.json", function(err, collection) {
// initialize the geocoder
geocoder = d3.geo.rasterCoder()
.size(960)
.features(collection.features);
// just for debugging
document.body.appendChild(geocoder.canvas());
// some LA locations
var total = 0;
var numCorrect = 0;
var numIncorrect = 0;
d3.select('body').selectAll('p')
.data(testDataSet)
.enter().insert('p', 'canvas')
.text(function(d) {
total++;
var neighborhood = geocoder(d.coords);
if (neighborhood) {
var answer = neighborhood.properties[property];
if (answer === d.answer) numCorrect++;
else numIncorrect++;
return JSON.stringify(d.coords) + ' : ' + (neighborhood && answer);
}
else {
numIncorrect ++;
}
})
console.log("Printing metrics");
console.log("Total: "+total);
console.log("Correct: "+numCorrect);
console.log("Incorrect: "+numIncorrect);
console.log("Accuracy: "+(d3.round(numCorrect/total, 3))+"%");
});
</script>
</body>
</html>