Giter Club home page Giter Club logo

cmat's Introduction

Confusion Matrix

A simple pandas/numpy-based module for constructing, analysing, and plotting confusion matrices that I found myself copying between projects so often that I decided to make it a separate, pip-installable package. It was written with python 3.6, but __future__ statements have been included and f-string have been avoided intentionally.

Installation

Install via pip (from PyPi)

pip install cmat

Or, alternatively, just copy the main module into your project and hardcode all config.xx values.

Usage

The functionality should be intuitive for anyone familiar with the confusion_matrix and classification_report from scikit-learn. Below follow basic instructions for instantiating the class.

To create a confusion matrix, do:

import cmat

cm = cmat.ConfusionMatrix.create(
  # 1D arrray with ground truth labels
  y_true = ground_truth,
  # 2D array with predictions
  y_pred = predictions
  # (optional) List of values that might occur in y_true/y_pred
  labels = class_labels
  # (optional) List of names corresponding to labels
  names = class_names
)

From there, you can get several metrics. A supplementary jupyter notebook has been included for more in depth documentation.

Development

Since the project is so small, no CI features have been added. There is, however, a small test suite which at the time of writing got 66% coverage on the main script.j Pylint has not been applied because it hates my intentation style.

Feel free to fork, post issues, or make pull requests if you have any suggestions to improvements.

Some possible TODOs include:

  • Plot for comparing multiple confusion matrices w.r.t. a specific metric. This could be useful for e.g. cross-validation comparisons
  • Support for adding sample or class weight when creating the matrix

cmat's People

Contributors

sherilan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.