mercury-monitoring
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. individual 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 appropriate 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.
Metadata
Release files for mercury-monitoring 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mercury_monitoring-1.2.1.tar.gz | 1.4 MB | Without provenance | Details for mercury_monitoring-1.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mercury_monitoring-1.2.1-py3-none-any.whl | Python 3 | none | any | Details for mercury_monitoring-1.2.1-py3-none-any.whl |
Total release size: 2.7 MB
Release files / mercury_monitoring-1.2.1.tar.gz
| Download URL | mercury_monitoring-1.2.1.tar.gz |
|---|---|
| Size | 1.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd192b6f02df70ed8eec6776012d11b21fcba8af5f73b26cb46acb1bd1cfcb97
|
|
BLAKE2b-256 checksum How to use checksums |
fbef177942d485143b53197ce1751c663878fc864012d8f8fe78a61639ee22ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / mercury_monitoring-1.2.1-py3-none-any.whl
| Download URL | mercury_monitoring-1.2.1-py3-none-any.whl |
|---|---|
| Size | 1.4 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c449b4648415781a54af50fb310a5a918572f3242e414e59a64b50e2af87671e
|
|
BLAKE2b-256 checksum How to use checksums |
28eca933597e6b38387e6992f2feeb158c9f4494a666f22cda676b262cbce578
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for mercury-monitoring 1.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.