Options
All
  • Public
  • Public/Protected
  • All
Menu

@fullexpression/confusion-matrix-stats

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!

Generated using TypeDoc