fscore

1.2.0 • Public • Published

!Travis build status

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 is null, will raise an error when using strings
  • beta : Beta parameter of the formula (See Fscore on wikipedia), default is 1
  • format : output format available possible values are basic, detailed, default is basic
    • basic only outputs the fscore
    • detailed 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
      }

Package Sidebar

Install

npm i fscore

Weekly Downloads

14

Version

1.2.0

License

MIT

Unpacked Size

17.8 kB

Total Files

12

Last publish

Collaborators

  • piercus