This repository has been archived by the owner on Oct 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
accuracy.php
107 lines (88 loc) · 3.54 KB
/
accuracy.php
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/* Author : Romain "Artefact2" Dalmaso <[email protected]>
* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details. */
require __DIR__.'/lib/inc.main.php';
declareCache('accuracy');
$accuracy = cacheFetch('accuracy', $success);
if(!$success) {
header('Content-Type: text/plain');
die('Accuracy data is not available. FUUUUUUUUU-');
}
$cols = "<tr>
<th rowspan='2'>▲ Pool</th>
<th colspan='5' title='Blocks found by the pool, with scores successfully indicating it was found by this pool.'><span>Accuracy</span></th>
<th rowspan='2' title='Number of blocks tested.'><span>Sample size</span></th>
</tr>
<tr>
<th>Most likely</th>
<th>Probably<br /><small>(or better)</small></th>
<th>Wild guess<br /><small>(or better)</small></th>
<th>Not sure at all<br /><small>(or better)</small></th>
<th title='Blocks found by the pool, but with scores indicating it was found by another pool.'><span>False positives</span></th>
</tr>";
$overallTotal = 0;
$overallCoeff = 0;
$round = function($p, $dec = 0) {
if(TONAL) return tonalNumberFormat($p * 0x100 / 100, $dec);
else return round($p, $dec);
};
$rows = '';
ksort($accuracy);
foreach($accuracy as $pool => $a) {
$rows .= "<tr>\n";
$rows .= "<td>".prettyPool($pool)."</td>\n";
$sSize = $a['sample_size'];
$p = @(100 * (
$a['accuracy'][C_MOST_LIKELY]
) / $a['sample_size']);
$rows .= "<td style='background-color: rgba(130, 160, 230, ".number_format($p / 100, 2).");'>".$round($p)." %</td>\n";
$overallTotal += $p * 6 * $sSize;
$p = @(100 * (
$a['accuracy'][C_MOST_LIKELY] + $a['accuracy'][C_PROBABLY]
) / $a['sample_size']);
$rows .= "<td style='background-color: rgba(151, 173, 211, ".number_format($p / 100, 2).");'>".$round($p)." %</td>\n";
$overallTotal += $p * 4 * $sSize;
$p = @(100 * (
$a['accuracy'][C_MOST_LIKELY] + $a['accuracy'][C_PROBABLY] + $a['accuracy'][C_WILD_GUESS]
) / $a['sample_size']);
$rows .= "<td style='background-color: rgba(170, 185, 207, ".number_format($p / 100, 2).");'>".$round($p)." %</td>\n";
$overallTotal += $p * 2 * $sSize;
$p = @(100 * (
$a['accuracy'][C_MOST_LIKELY] + $a['accuracy'][C_PROBABLY] + $a['accuracy'][C_WILD_GUESS] + $a['accuracy'][C_NOT_SURE_AT_ALL]
) / $a['sample_size']);
$rows .= "<td style='background-color: rgba(178, 189, 187, ".number_format($p / 100, 2).");'>".$round($p)." %</td>\n";
$overallTotal += $p * $sSize;
$p = @(100 * $a['false_positives'] / $a['sample_size']);
$rows .= "<td style='background-color: rgba(255, 80, 80, ".number_format($p / 100, 2).");'>".$round($p)." %</td>\n";
$rows .= "<td>".formatInt($sSize)."</td>\n";
$rows .= "</tr>\n";
$overallCoeff += 13 * $sSize;
}
$overall = $round($overallTotal / $overallCoeff, 2);
echo "<!DOCTYPE html>
<html>
<head>
".HEADER."
<title>Score accuracy</title>
</head>
<body>
<h1>Score accuracy <small>(<span title='Weighted average of invividual pool accuracies (weighted by sample size).'>overall accuracy: $overall %</span>)</small></h1>
<p id='back'><a href='/'>← Back to the main page</a></p>
<p class='notice'>The results below may be biased, since the tests were only done on blocks found by their respective pool. These testing conditions do not represent exactly the <em>unknown block</em> scenario.</p>
<table id='accuracy'>
<thead>
$cols
</thead>
<tbody>
$rows
</tbody>
</table>
";
echo FOOTER."
</body>
</html>
";