FullExpression / confusion-matrix-stats

πŸš€This library aims to facilitate the calculations of several metrics using a multi-dimensional confusion matrix. πŸ“š Provides a set of features, not only to obtain metrics such as accuracy, precision and f1Score, but also matrix normalization, cloning, and the number of predictions.
MIT License
5 stars 0 forks source link
angular angularjs artificial-intelligence calculations deep-learning javascript machine-learning matrix metrics nodejs typescript vue vuejs

Confusion Matrix Statistics Calculations

production-build production-build production-build

production-build Coverage Branches Coverage Branches Coverage Branches Coverage Branches

As the name suggests, this library aims to facilitate the calculations of several metrics using a multi-dimensional confusion matrix.

Provides a set of feature, not only to obtain matrix such as accuracy, precision and f1Score, but also matrix normalization, cloning, numberOfPredictions, etc.

This library was inspired on scikit-learn confusion-matrix written for python. Our goal is to create the same concept for the javascript world.

πŸ› οΈ How to install

Run the following command:

npm install confusion-matrix-stats

πŸ‘©β€πŸ’» How to use it

You just need to create a new Confusion Matrix instance:

const confusionMatrix = new ConfusionMatrix({
    labels: ["Happiness", "Sadness", "Disgust"], 
    matrix: [[50, 2, 3],
             [8, 50 ,5],
             [2, 5 ,50]]
});

And then, call the function to obtain the desired metric:

// Calculates the accuracy value for the all matrix.
const accuracy = confusionMatrix.accuracy();

For each metric calculation, is possible to define a different configurations in order to fine tune the calculation formula:

// Calculates the f1Score, only for "sadness" class, using the Macro average method.
const labelAccuracy = confusionMatrix.f1Score({ label: "Sadness", average: AverageMethod.Macro});

πŸ‘©πŸ»β€πŸ« Examples

You have in here examples for different languages/frameworks.

πŸ“š Documentation

You can the library documentation here.

πŸ€“ Give us your feedback

Please, give us your feedback here! Also, participate in this project using ricardo1992rocha@gmail.com email contact.

Thank you!