Skip to content

Commit

Permalink
validate: better output
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Oct 24, 2020
1 parent 8bb502d commit 14d7581
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/validate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ async function main(filename) {
}
}

console.time('predict');
let prediction = await model.predict(tf.tensor(xs));
prediction = await prediction.squeeze(-1).exp().mul(440).array();
console.timeEnd('predict');
prediction = await prediction.squeeze(-1)
.div(100).mul(Math.log(2))
.exp().mul(440).array();

const errors = new Map();
for (const [ i, freq ] of ys.entries()) {
const predicted = prediction[i];
const error = Math.abs(predicted / freq - 1);
const error = Math.abs(Math.log(predicted / freq) / Math.log(2) * 100);

if (errors.has(freq)) {
errors.get(freq).push(error);
Expand All @@ -64,14 +68,16 @@ async function main(filename) {
return b.mean - a.mean;
});

const bestMean = list[list.length - 1];
console.log('best mean', bestMean);

const worstMean = list[0];
console.log(worstMean);
console.log('worst mean', worstMean);

list.sort((a, b) => {
return b.stddev - a.stddev;
});


const worstStddev = list[0];
console.log(worstMean);
}
Expand Down

0 comments on commit 14d7581

Please sign in to comment.