fscore
v1.2.0
Published
Nodejs F1 score (also called F-score or F-measure)
Downloads
126
Maintainers
Readme
fscore
Nodejs F1 score (also called F-score or F-measure) or any other Fbeta-score
See more informations about F1 Score
install
npm install fscore
usage
fscore(actual, expected, options);
basic
var fscore = require("fscore");
fscore([22, 34, 55, 52, 56, 79, 123, 678, 89, 567], [34, 55, 22, 33, 45]);
// -> 0.4
with strings
var fscore = require("fscore");
fscore(['foo', 'bar', '55', '52', '56', '79', '123', '678', '89', '567'], ['bar', '55', 'foo', '33', '45']);
// returns 0.4
with tolerance
var fscore = require("fscore");
fscore([22, 34, 55, 52, 56, 79, 123, 678, 89, 567], [34.2, 55.1, 21.9, 32.8, 45.1], { tolerance : 0.2 });
// returns 0.4
F-Beta score
var fscore = require("fscore");
fscore([22, 34, 55, 52, 56], [34, 55, 22, 33, 45], { beta : 0.5 });
// return 0.6
Detailed result
var fscore = require("fscore");
fscore([22, 34, 55, 52, 56], [34, 55, 22, 33, 45], { beta : 0.5, format : 'detailed' });
// return 0.6
Options
tolerance
: Define a tolerance for the matching between actual and expected, default isnull
, will raise an error when using stringsbeta
: Beta parameter of the formula (See Fscore on wikipedia), default is1
format
: output format available possible values arebasic
,detailed
, default isbasic
basic
only outputs the fscoredetailed
outputs{ fscore : 0.4, //the fscore tPositive : 2, //number of true positives precision : 0.4, //precision recall : 0.4, //recall tPositiveIndexes: [[0, 0], [1, 1]], // indexes of true positives matches fNegativeIndexes: [2, 3],// indexes of false negatives fPositiveIndexes: [2, 3] // indexes of false positives }