Skip to main content

Mercury's monitoring is a library to perform monitoring testing on models and/or datasets..

Project description

mercury-monitoring

Python 3.8 Python 3.9 Python 3.10 Python 3.11 Python 3.12 Python 3.13 Apache 2 license Ask Me Anything !

mercury-monitoring is a library to monitor data and model drift. It contains a set of utilities which you can use for detecting in advance whether the statistical properties of your data have changed and whether your model's performance is getting worse.

Among others, you can check things like:

  • Changes in your entire data distribution (P(X))
  • Changes in your marginals (i.e. individial features P(Xi))
  • Estimated performance of your model when you don't have access to the true labels

and take the actions you consider pertinent (e.g. retrain your model on more recent data, generate alerts, etc.).

Most of the classes for detecting drift have a calculate_drift() method which will yield the predicted result on whether drift has been detected or not.

Usage example

from mercury.monitoring.drift.domain_classifier_drift import DomainClassifierDrift

# Create example datasets
X_src = np.array([np.random.normal(0, 1, 1000), np.random.normal(0, 1, 1000)]).T
X_target = np.array([np.random.normal(0, 1, 500) + 2, np.random.normal(0, 1, 500)]).T

# Calculate drift
drift_detector = DomainClassifierDrift(
    X_src,                    # Source dataset
    X_target,                 # Target dataset (e.g. newer batch of data)
    features=["f1", "f2"],
    p_val=0.01,
    test_size=0.3,
    n_runs=10
)

# Get results
drift_metrics = drift_detector.calculate_drift()

# Print the results
print("Drift Score: ", drift_metrics["score"])
print("p_val: ", drift_metrics["p_val"])
print("Is drift detected? ", drift_metrics["drift_detected"])

# Plot drift scores per feature
drift_detector.plot_feature_drift_scores(figsize=(8,4))

Feel free to explore more of the drift detectors and use the most appropiate for your use case.

Documentation

We encourage you checking the documentation of this package at: https://bbva.github.io/mercury-monitoring/site/ and taking a look at the available notebook tutorials.

Mercury project at BBVA

Mercury is a collaborative library that was developed by the Advanced Analytics community at BBVA. Originally, it was created as an InnerSource project but after some time, we decided to release certain parts of the project as Open Source. That's the case with the mercury-monitoring package.

If you're interested in learning more about the Mercury project, we recommend reading this blog post from www.bbvaaifactory.com

User installation

The easiest way to install mercury-monitoring is using pip:

pip install -U mercury-monitoring

Help and support

This library is currently maintained by a dedicated team of data scientists and machine learning engineers from BBVA. In case you find any bug, have an idea or request feel free to open a ticket on the Issues section.

Email

mercury.group@bbva.com

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

mercury_monitoring-1.1.3.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

mercury_monitoring-1.1.3-py3-none-any.whl (1.4 MB view details)

Uploaded Python 3

File details

Details for the file mercury_monitoring-1.1.3.tar.gz.

File metadata

  • Download URL: mercury_monitoring-1.1.3.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mercury_monitoring-1.1.3.tar.gz
Algorithm Hash digest
SHA256 ce9a495131e24390eb8b4c7294998711f82c800162b348ff2b0365a0a18e0e24
MD5 4cfdbc8d2313d7192fd204a5c4249110
BLAKE2b-256 c718997d6405376b37c039132fa641620103850221d39ac93ccf1acd44db7381

See more details on using hashes here.

File details

Details for the file mercury_monitoring-1.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for mercury_monitoring-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5e47fd87c5234af995f315493ab00e429b5387c6aa712066a18bf590a5ed0ebf
MD5 bb5457a0f0652abd27685905b3bdd7a5
BLAKE2b-256 ab14f993896308faa97110096bb2ec01076cbb10ab9829549b9215fbdfa035a5

See more details on using hashes here.

Supported by

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