Skip to main content

Python SDK for monitoring and validating Machine Learning models.

Project description

MLSentinel logo

MLSentinel

PyPI Python License PyPI Downloads

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.6.dev3.tar.gz (12.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.6.dev3-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mlsentinel-0.1.6.dev3.tar.gz
  • Upload date:
  • Size: 12.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.6.dev3.tar.gz
Algorithm Hash digest
SHA256 fe560a1476f504ad612fd7d86dc5d09e703f19cf217603a0954569351efbdca1
MD5 aec7a29206584b384a78a1eead1279b0
BLAKE2b-256 ef3a1d86ab7ed3d8c04b7bdbda12eb8186573ebe92a5c961d0be11db9405ffa7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlsentinel-0.1.6.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 2bddbf8f8b8000f7ac1b0dae68bf44ea6382dd5af9d0ba2e083f73b027663975
MD5 d11af871576f78624fb13fab0e31b0e2
BLAKE2b-256 48bf33ce761757e5a9cbef98d46e399158f9a7b2e911450737f4ae143ef5c4f6

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