This release is a pre-release and may not be stable for production use.
MLSentinel SDK
MLSentinel SDK is the Python client for sending model evaluation reports and data-quality summaries to the MLSentinel platform. It keeps the workflow simple: validate locally, send with your API key, and get back a structured JSON response or a clear SDK error.
Installation
The SDK supports Python 3.9 and newer.
Install from PyPI:
pip install mlsentinel
Or install from a local checkout while developing:
pip install .
Quick Start
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())
Keep API keys out of source control. In real projects, read them from environment variables or a secret manager instead of hard-coding them.
What the SDK Does
MLSentinel SDK is designed to stay out of your way:
- validates
project,model, andmetricsbefore making a network request - sends reports to the backend using the
X-API-Keyheader - returns the API response as JSON when the request succeeds
- raises SDK-specific exceptions when validation, authentication, network, or server handling fails
- can also generate and upload a data-quality summary from a pandas DataFrame
Data Quality Reports
If you want a quick health snapshot of a dataset, the SDK can summarize it locally and send the result to the platform.
import pandas as pd
from mlsentinal import MLDoc
df = pd.read_csv("creditcard.csv")
client = MLDoc("YOUR_API_KEY")
response = client.report_data_quality(
project="Loan Prediction",
model="ResNet50",
dataframe=df,
)
print(response)
This feature requires pandas and numpy.
Validation Rules
Every report expects a non-empty string for both project and model. The metrics argument must be a non-empty dictionary, and only the supported metrics below are accepted.
| 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 happens locally first, so malformed payloads are caught before a request leaves your machine.
Errors
The SDK raises its own exception types so you can handle failures cleanly in one place.
from mlsentinal import MLDoc
from mlsentinal.exceptions import MLSentinelError
client = MLDoc("YOUR_API_KEY")
try:
client.doc_report(
project="Spam Detector",
model="Random Forest",
metrics={"accuracy": 1.2},
)
except MLSentinelError as error:
print(error.code)
print(error.message)
| Situation | Exception |
|---|---|
| Invalid project, model, or metrics | ProjectValidationError, ModelValidationError, MetricValidationError |
| Invalid API key | InvalidAPIKeyError |
| Authentication or authorization failure | AuthenticationError |
| Timeout, connection, or request failure | MLSentinalConnectionError |
| Unexpected API response or server failure | MLSentinalServerError |
API Reference
MLDoc(api_key, check_version=True)
Creates a client for the MLSentinel platform. The client can optionally check SDK compatibility during initialization.
client.doc_report(project, model, metrics)
Validates and submits a model report. On success, it returns the JSON response from the backend.
client.report_data_quality(project, model, dataframe)
Builds a local data-quality summary and submits it to the backend.
client.version()
Returns the installed SDK version.
Requirements
- Python 3.9+
requests2.31.0+
License
MLSentinel is distributed under the MIT License.
Author
Created by Adari Narasimha Dhoni.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mlsentinel-0.1.6.dev4.tar.gz.
File metadata
- Download URL: mlsentinel-0.1.6.dev4.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c572b22989ee1de3decf3017f7fc5c31de8d7604960373bc85108665138aac2f
|
|
| MD5 |
858f6c956b0ef8aef20566cac6f20777
|
|
| BLAKE2b-256 |
a1d7afc0b0c12d0e3a645f4085c994fb4bbf774e5a59f496847ef7a89188d35c
|
File details
Details for the file mlsentinel-0.1.6.dev4-py3-none-any.whl.
File metadata
- Download URL: mlsentinel-0.1.6.dev4-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47f085c2e659790e42eaee7686ffb52284e02dfb91a26f358a8ee007a7baefeb
|
|
| MD5 |
733e35d2d5cb121c60e9ae9c8ae5d61d
|
|
| BLAKE2b-256 |
63ca5fd70f8fa0b1eb6b1fc3affda2d6ec1a80a3233057c649e77e574dfec3de
|