Skip to main content

A Python library to help make your Machine Learning easier

Project description

Beluga - make predictions, get metrics

License Code Style Last Commit Contributors Size Issues Discord

Beluga is a Python library that provides easy access to all of the metrics you need in your multiclass classification tasks. We were inspired by this friendly Beluga whale to help others in their Machine Learning projects.

Check out the Issues for future functionality and progress such as support for regression tasks and metric visualisations.

The official PyPi release can be found here.

Overview

  • Get various metrics on your Machine Learning predictions
  • Print your metrics or incorporate them into downstream analysis
  • Visualise your metrics (Coming Soon)

Installation

To install this library you can use Pypi via pip

pip install beluga_ml

Usage

Import beluga into your project

import beluga

Documentation

Methods in metrics have following parameters:

  • predictions - (Iterable) predictions output from your model
  • ground_truth - (Iterable) ground truth values to compare against
  • raw - (bool). Optional. Use to get metrics in a dictionary instead of printing. Default: False.

Methods list:

true_positive: Number of correctly classified labels of the positive class

true_negative: Number of correctly classified labels of the negative class

false_positive: Number of incorrectly classified labels of the postive class

false_negative: Number of incorrectly classified labels of the negative class

precision: Percentage of positive class predictions that are correct

recall: Percentage of correctly classified labels from the positive class

sensitivity: (see recall)

specificity: Percentage of correctly classified labels from the negative class

f1: The harmomic mean of precision and recall

accuracy: Percentage of correctly classified labels

Examples

beluga.metrics.true_positive([1, 1, 1, 0, 0], [1, 0, 1, 0, 0])
>>> True Positive
    ==============
    0       2.0000
    1       2.0000
    ==============

beluga.metrics.recall(['cat', 'dog', 'dog'], ['cat', 'dog', 'dog'])
>>> Recall
    ==============
    cat     1.0000
    dog     1.0000
    ==============

beluga.metrics.f1(['Elon Musk', 'Tim Cook', 'robot'], ['Elon Musk', 'Tim Cook', 'Mark Zuckerberg'])
>>> F1 score
    ========================
    Elon Musk         1.0000
    Mark Zuckerberg   0.0000
    Tim Cook          1.0000
    ========================

Running Code

Run the code from the home direcotry for any development as follows:

python -m beluga.metrics

This should return nothing as all development tests have been removed.

Tests

Run the tests from the library home directory with the following:

python -m setup pytest

Check the coverage of these tests using:

pytest --cov=beluga tests/ --cov-report term-missing

License

GPL-3.0 License

Beluga uses open source packages to work properly:

  • numpy - The fundamental package for scientific computing with Python.

And of course beluga itself is open source with a public repository on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

beluga_ml-1.0.1-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file beluga_ml-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: beluga_ml-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.10

File hashes

Hashes for beluga_ml-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1cf897026fe07b731200a26fc9ab8d8999f42ac1de1e6860f928381180675bc4
MD5 791978a108eacb9b7af3c491cf1fc844
BLAKE2b-256 a3be2b91e1e29696082dcead0850587e0aadf8b92958cdff5f3f4ddec6896438

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page