Skip to main content

Simple python package to sanitize in a standard way ML-related labels.

Project description

Pypi project Pypi total project downloads

Simple python package to sanitize in a standard way ML-related labels.

How do I install this package?

As usual, just download it using pip:

pip install sanitize_ml_labels

Tests Coverage

I have strived to mantain a 100% code coverage in this project:

Module

statements

missing

excluded

coverage

Total

84

0

0

100%

sanitize _ml_labels/__init__.py

3

0

0

100%

sanitize_ml _labels/__version__.py

1

0

0

100%

sanitize_ml_labels/is _normalized_metric.py

10

0

0

100%

sanitize_ml_labels /sanitize_ml_labels.py

70

0

0

100%

You can verify the test coverage of this repository by running in its root:

pytest --cov

Why do I need this?

So you have some kind of plot and you have some ML-related labels. Since I always rename and sanitize them the same way, I have prepared this package to always sanitize them in a standard fashion.

Usage examples

Here you have a couple of common examples: you have a set of metrics to normalize or a set of model names to normalize.

from sanitize_ml_labels import sanitize_ml_labels

# Example for metrics
labels = [
    "acc",
    "loss",
    "auroc",
    "lr"
]

sanitize_ml_labels(labels)

# ["Accuracy", "Loss", "AUROC", "Learning rate"]

# Example for models
labels = [
    "vanilla mlp",
    "vanilla cnn",
    "vanilla ffnn",
    "vanilla perceptron"
]

sanitize_ml_labels(labels)

# ["MLP", "CNN", "FFNN", "Perceptron"]

Extra utilities

Since I always use metric sanitization alongside axis normalization, it is useful to know which axis should be maxed between zero and one to avoid any visualization bias to the metrics.

For this reason I have created the method is_normalized_metric, which after having normalized the given metric validates it against known normalized metrics (metrics between 0 and 1, is there another name? I could not figure out a better one).

Analogously, I have also created the method is_absolutely_normalized_metric to validate a metric for the range between -1 and 1.

from sanitize_ml_labels import is_normalized_metric, is_absolutely_normalized_metric

is_normalized_metric("MSE") # False
is_normalized_metric("acc") # True
is_normalized_metric("accuracy") # True
is_normalized_metric("AUROC") # True
is_normalized_metric("auprc") # True
is_absolutely_normalized_metric("auprc") # False
is_absolutely_normalized_metric("MCC") # True
is_absolutely_normalized_metric("Markedness") # True

New features and issues

As always, for new features and issues you can either open a new issue and pull request. A pull request will always be the quicker way, but I’ll look into the issues when I get the time.

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

sanitize_ml_labels-1.0.35.tar.gz (7.7 kB view details)

Uploaded Source

File details

Details for the file sanitize_ml_labels-1.0.35.tar.gz.

File metadata

  • Download URL: sanitize_ml_labels-1.0.35.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.9

File hashes

Hashes for sanitize_ml_labels-1.0.35.tar.gz
Algorithm Hash digest
SHA256 16b6b08fc1691d297ad3502480d3d52d08dcbe87919f97093bfb7411836316fb
MD5 db17aa1c7ca987662666dd2ad48e070b
BLAKE2b-256 9d6861c09d53b185a6a63c57f5ef6e39133a649db2642356f86ef4bfaac82544

See more details on using hashes here.

Provenance

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