Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
'use strict';
|
||||
|
||||
function sum(array) {
|
||||
return array.reduce(function (a, b) {
|
||||
return a + b;
|
||||
});
|
||||
}
|
||||
|
||||
function square(x) {
|
||||
return x * x;
|
||||
}
|
||||
|
||||
function mean(array) {
|
||||
return sum(array) / array.length;
|
||||
}
|
||||
|
||||
function averageSquareDiff(a, predictions) {
|
||||
return mean(predictions.map(function (x) {
|
||||
return square(x - a);
|
||||
}));
|
||||
}
|
||||
|
||||
function diversityTheorem(truth, predictions) {
|
||||
var average = mean(predictions);
|
||||
return {
|
||||
'average-error': averageSquareDiff(truth, predictions),
|
||||
'crowd-error': square(truth - average),
|
||||
'diversity': averageSquareDiff(average, predictions)
|
||||
};
|
||||
}
|
||||
|
||||
console.log(diversityTheorem(49, [48,47,51]))
|
||||
console.log(diversityTheorem(49, [48,47,51,42]))
|
||||
Loading…
Add table
Add a link
Reference in a new issue