Skip to main content

Python SDK for monitoring and validating Machine Learning models.

Project description

MLSentinel logo

MLSentinel

PyPI Python License

Validate and submit machine-learning evaluation metrics from Python.

MLSentinel is a lightweight Python SDK for sending model evaluation reports to the MLSentinel platform. It validates report data locally, authenticates requests with your API key, and returns the platform response as JSON.

Developer preview — v0.1.3.dev3

This pre-release focuses on reliable report submission: local validation, HTTP transport, API-key authentication, and actionable SDK errors. Analysis and dashboard features are planned for later releases.

Installation

MLSentinel supports Python 3.9 and later.

pip install mlsentinel

For this development build, install from a local checkout:

pip install .

Quick start

Create an API key in the MLSentinel platform, then submit a report:

from mlsentinal import MLDoc

client = MLDoc("YOUR_API_KEY")

response = client.doc_report(
    project="Spam Detector",
    model="Random Forest",
    metrics={
        "accuracy": 0.95,
        "precision": 0.94,
        "recall": 0.93,
        "f1_score": 0.935,
        "roc_auc": 0.98,
        "val_loss": 0.18,
    },
)

print(response)
print(client.version())  # 0.1.3.dev3

Keep API keys out of source control. In production, load the key from your secret manager or environment rather than embedding it in code.

What happens when you submit a report

Your application
      │
      ▼
MLDoc.doc_report(...)
      │
      ├─ Local input validation
      │
      └─ HTTP request with X-API-Key
                    │
                    ▼
            MLSentinel API
                    │
                    ▼
            JSON response or SDK exception

Supported metrics and validation

All reports require a non-empty string for both project and model. The metrics argument must be a non-empty dictionary containing only the supported metrics below.

Metric Accepted value
accuracy Number from 0 to 1
precision Number from 0 to 1
recall Number from 0 to 1
f1_score Number from 0 to 1
roc_auc Number from 0 to 1
val_loss Number greater than or equal to 0

Validation occurs before a network request is made, helping you catch malformed reports early.

Error handling

MLSentinel raises SDK-specific exceptions with stable error codes. Catch the common base class when you want one error path for validation, authentication, network, and server failures.

from mlsentinal import MLDoc
from mlsentinal.exceptions import MLSentinalError

client = MLDoc("YOUR_API_KEY")

try:
    client.doc_report(
        project="Spam Detector",
        model="Random Forest",
        metrics={"accuracy": 1.2},
    )
except MLSentinalError as error:
    print(error.code)     # for example: MLS026
    print(error.message)  # accuracy must be between 0 and 1.
Category Exception
Invalid project, model, or metrics ProjectValidationError, ModelValidationError, MetricValidationError
Invalid API key InvalidAPIKeyError
Authentication or authorization failure AuthenticationError
Timeout, connection, or request error MLSentinalConnectionError
Unexpected API response or server error MLSentinalServerError

Version 0.1.3.dev3

This development release adds and improves:

  • Standardized SDK error codes for validation, network, authentication, and server failures.
  • Clearer exception messages for unsupported and invalid metric values.
  • HTTP report transport with API-key authentication through the X-API-Key header.
  • Timeout and connection-error handling.
  • Local validation of projects, models, and supported evaluation metrics.

API reference

MLDoc(api_key)

Creates a client authenticated with the supplied API key.

client.doc_report(project, model, metrics)

Validates and submits a model report. On success, it returns the JSON body returned by the MLSentinel API. On failure, it raises an MLSentinalError subclass.

client.version()

Returns the installed SDK version.

Requirements

  • Python 3.9+
  • requests 2.31.0+

Roadmap

  • AI-assisted model analysis and health reports
  • Performance recommendations and diagnostics
  • Dashboard and report history
  • Model monitoring and drift detection
  • CI/CD integrations

Contributing

Contributions are welcome. Please open an issue to discuss significant changes, then submit a focused pull request with tests or examples where appropriate.

License

MLSentinel is distributed under the MIT License.

Author

Created by Adari Narasimha Dhoni.

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

mlsentinel-0.1.3.dev3.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mlsentinel-0.1.3.dev3-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file mlsentinel-0.1.3.dev3.tar.gz.

File metadata

  • Download URL: mlsentinel-0.1.3.dev3.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for mlsentinel-0.1.3.dev3.tar.gz
Algorithm Hash digest
SHA256 b5f22959088fcc35b8b1cbd48a72ad4a332de4876ac818ece4120a1382ae2529
MD5 7bd3bbc769e8089885eba4d16dba2088
BLAKE2b-256 96d1e10dc9d64e56c3d29a6444b2737576792134d8ed001d7887497ec840d1e5

See more details on using hashes here.

File details

Details for the file mlsentinel-0.1.3.dev3-py3-none-any.whl.

File metadata

File hashes

Hashes for mlsentinel-0.1.3.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 f3db4feb4988039b41ff9c48e235b7f93e169aa3d37aff178d86cb01c0d54150
MD5 9363525cd4643047974ce12e380d9e32
BLAKE2b-256 256a4f3c2d01c36b18ad661c13dcb845c8c6792ba4d2d823968839dc621ffae3

See more details on using hashes here.

Supported by

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