Skip to main content

Metrics Library to Evaluate Machine Learning Algorithms in Python

Project description

PyPI version PyPI - License codecov PyPI - Python Version

onemetric

Logo

Installation

  • Install onemetric from PyPI (recommended):

    pip install onemetric
    
  • Install onemetric from the GitHub source:

    git clone https://github.com/SkalskiP/onemetric.git
    cd onemetric
    python setup.py install
    

Example

dataset-sample

Figure 1. Dataset sample, blue - ground-truth and red - detection.

Calculate mAP@0.5

>>> from onemetric.cv.loaders import YOLOLoader
>>> from onemetric.cv.object_detection import MeanAveragePrecision

>>> model = load_model(...)  # model-specific loading method

>>> data_set = YOLOLoader(
...     images_dir_path=DATA_SET_IMAGES_PATH, 
...     annotations_dir_path=DATA_SET_ANNOTATIONS_PATH
... ).load()

>>> true_batches, detection_batches = [], []
>>> for entry in data_set:
>>>     detections = model(entry.get_image())  # model-specific prediction method
>>>     true_batches.append(entry.get_annotations())
>>>     detection_batches.append(detections)

>>> mean_average_precision = MeanAveragePrecision.from_detections(
...     true_batches=true_batches, 
...     detection_batches=detection_batches, 
...     num_classes=12,
...     iou_threshold=0.5
... )

>>> mean_average_precision.value
0.61

Calculate Confusion Matrix

>>> confusion_matrix = ConfusionMatrix.from_detections(
...     true_batches=true_batches, 
...     detection_batches=detection_batches,
...     num_classes=12
... )

>>> confusion_matrix.plot(CONFUSION_MATRIX_TARGET_PATH, class_names=CLASS_NAMES)

dataset-sample

Figure 2. Create confusion matrix chart

Documentation

The official documentation is hosted on Github Pages: https://skalskip.github.io/onemetric

Contribute

Feel free to file issues or pull requests. Let us know what metrics should be part of onemetric!

Citation

Please cite onemetric in your publications if this is useful for your research. Here is an example BibTeX entry:

@MISC{onemetric,
   author = {Piotr Skalski},
   title = {{onemetric}},
   howpublished = "\url{https://github.com/SkalskiP/onemetric/}",
   year = {2021},
}

License

This project is licensed under the BSD 3 - see the LICENSE file for details.

Project details


Download files

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

Source Distribution

onemetric-0.1.2.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

onemetric-0.1.2-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file onemetric-0.1.2.tar.gz.

File metadata

  • Download URL: onemetric-0.1.2.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/57.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.6

File hashes

Hashes for onemetric-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1f50d65d1722ebd9ee55c4580fb9dc8e35400529e3986afb6a39560c75a974e5
MD5 612b64b9b7e9ada4f508a45bc17c9012
BLAKE2b-256 d386454ee9b070881afbc79baa44fd9b6577510c671e000bafd0121e42896af1

See more details on using hashes here.

File details

Details for the file onemetric-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: onemetric-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/57.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.6

File hashes

Hashes for onemetric-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2ac57e267f4997ee59e8784679f54cbd4969b97ec220794de294a2c34f1f353d
MD5 278d6b87cc2ac552b0ec2431f66b94c9
BLAKE2b-256 f0165a806acc0929b661b6ce273f099fdb4a2a48055c9fa298dddce038d15c19

See more details on using hashes here.

Supported by

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