Created
August 28, 2020 17:53
-
-
Save allanchua101/096dc6e529b4fdb1ff74658b0703981c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
try { | |
let [classifier, data] = await Promise.all([loadFrozenModel(), loadData()]); | |
let results = data.map((i, idx) => { | |
let actual = getLabel(i.class_id); | |
let predicted = classifier.classify(i.tweet); | |
console.clear(); | |
console.log(`Inferring Item ${idx + 1} out of ${data.length}`); | |
return { | |
tweet: i.tweet, | |
actual, | |
predicted, | |
isCorrect: actual === predicted, | |
}; | |
}); | |
let accurateHit = results.filter((i) => i.isCorrect); | |
let missedItems = results.filter((i) => !i.isCorrect); | |
let accuracy = (accurateHit.length / data.length) * 100; | |
let errorRate = (missedItems.length / data.length) * 100; | |
console.log(`Accurate: ${accurateHit.length} items`); | |
console.log(`Missed: ${missedItems.length} items`); | |
console.log(`Accuracy: ${accuracy.toFixed(2)}`); | |
console.log(`Error Rate: ${errorRate.toFixed(2)}`); | |
} catch (err) { | |
console.log(err.message); | |
console.log(err.stack); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment