Skip to main content

mlwatch 🔍

Lightweight ML monitoring — drift detection, performance tracking, data quality & alerts in one library.

PyPI version Python License: MIT


Why mlwatch?

mlwatch Evidently WhyLogs
Simple API ✅ ❌ ❌
Lightweight ✅ ❌ ❌
JSON output ✅ ❌ ❌
No setup needed ✅ ❌ ❌
SQLite history ✅ ❌ ❌

Install

pip install mlwatch

Quickstart

import mlwatch
import numpy as np
import pandas as pd

# Your training data
train_data = pd.DataFrame({
    "age":    np.random.normal(30, 5, 1000),
    "income": np.random.normal(50000, 10000, 1000),
})

# New incoming data
new_data = pd.DataFrame({
    "age":    np.random.normal(45, 5, 500),  # shifted!
    "income": np.random.normal(50000, 10000, 500),
})

# Monitor your model
monitor = mlwatch.Monitor(name="my_model")

result = monitor.log(
    reference=train_data,
    current=new_data,
    y_true=actual_labels,
    y_pred=model_predictions,
)

print(result.to_dict())

Features

1. Drift Detection

Detects when your input data distribution has changed.

from mlwatch import detect

result = detect(reference_data, current_data)
# {
#   "drifted": True,
#   "features": {
#     "age":    { "drifted": True,  "ks": {...}, "psi": {...} },
#     "income": { "drifted": False, "ks": {...}, "psi": {...} }
#   }
# }

Supported methods:

  • KS Test — Kolmogorov-Smirnov statistical test
  • PSI — Population Stability Index
  • Mean Shift — normalized mean difference

2. Performance Monitoring

Tracks model accuracy over time and alerts on degradation.

from mlwatch import track

# Classification
result = track(y_true, y_pred, task="classification")
# { "accuracy": 0.91, "f1": 0.89, "degraded": False }

# Regression
result = track(y_true, y_pred, task="regression")
# { "mae": 0.03, "rmse": 0.05, "r2": 0.97, "degraded": False }

3. Data Quality

Catches nulls, outliers, and schema issues before they break your model.

from mlwatch import check

result = check(dataframe)
# {
#   "nulls":    { "age": 3 },
#   "outliers": { "income": 7 },
#   "passed":   False,
#   "issues":   ["nulls found in columns: ['age']"]
# }

4. Alerts

Get notified when something goes wrong.

from mlwatch import Monitor
from mlwatch.alerts import AlertConfig

monitor = Monitor(
    name="my_model",
    alerts=AlertConfig(
        webhook="https://hooks.slack.com/...",
        on_drift=lambda data: print("Drift detected!", data),
        on_degradation=lambda data: print("Model degraded!", data),
    )
)

5. History

All results are saved to SQLite automatically.

monitor = mlwatch.Monitor(name="my_model", storage="mlwatch.db")

# Get last 50 logs
history = monitor.history.get("my_model", limit=50)

Full Example

import mlwatch
import numpy as np
import pandas as pd
from mlwatch.alerts import AlertConfig

monitor = mlwatch.Monitor(
    name="purchase_model",
    storage="mlwatch.db",
    alerts=AlertConfig(
        on_drift=lambda d: print("⚠️  Drift detected!", d),
        on_degradation=lambda d: print("📉 Model degraded!", d),
    )
)

result = monitor.log(
    reference=train_data,
    current=new_data,
    y_true=y_true,
    y_pred=y_pred,
    task="classification",
    thresholds={"accuracy": 0.85, "f1": 0.80},
)

print(result.to_dict())

API Reference

mlwatch.Monitor

Parameter Type Default Description
name str required Model name
storage str mlwatch.db SQLite path
alerts AlertConfig None Alert configuration

monitor.log()

Parameter Type Default Description
reference DataFrame/ndarray required Training data
current DataFrame/ndarray required New data
y_true ndarray None Ground truth labels
y_pred ndarray None Model predictions
task str classification classification or regression
thresholds dict None Custom degradation thresholds

License

MIT

Metadata

Release files for mlwatch 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mlwatch 0.1.1
File Size Uploaded Provenance Actions
mlwatch-0.1.1.tar.gz 6.9 kB Without provenance Details for mlwatch-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mlwatch 0.1.1
File Interpreter ABI Platform Actions
mlwatch-0.1.1-py3-none-any.whl Python 3 none any Details for mlwatch-0.1.1-py3-none-any.whl

Total release size: 18.0 kB

Release files / mlwatch-0.1.1.tar.gz

Download URL mlwatch-0.1.1.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7b38ddc32cadad6b7781009bdcc7c79b1755b209404726357243bd51a75c94ff
BLAKE2b-256 checksum
How to use checksums
e84d6716cf70ee504d3a383e7b3615cd4cba585d95f3bd2c06a9b4149fecbc11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / mlwatch-0.1.1-py3-none-any.whl

Download URL mlwatch-0.1.1-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dad5b2db45c07519d525ae87087a7a463ce39712eaf17c7c2416dbc44d03bbcf
BLAKE2b-256 checksum
How to use checksums
f7b0a3474ada2786293dbfc9e6a4f8b48bd8aee2a11ac3811c6abaf7aaac0d7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Security for mlwatch 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page