Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

MLSentinel logo

MLSentinel SDK

PyPI Python License PyPI Downloads

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, and metrics before making a network request
  • sends reports to the backend using the X-API-Key header
  • 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+
  • requests 2.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

mlsentinel-0.1.7.dev5.tar.gz (18.9 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.7.dev5-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file mlsentinel-0.1.7.dev5.tar.gz.

File metadata

  • Download URL: mlsentinel-0.1.7.dev5.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.2

File hashes

Hashes for mlsentinel-0.1.7.dev5.tar.gz
Algorithm Hash digest
SHA256 3dac378661f1a9719d750340696248246086fc033223381568632f52490af179
MD5 4488045bf5292d085c160c3ca4647743
BLAKE2b-256 a44dd4d88d43348c5ed1a7e5c096957455327d26eae792d8a869a662173bcea2

See more details on using hashes here.

File details

Details for the file mlsentinel-0.1.7.dev5-py3-none-any.whl.

File metadata

File hashes

Hashes for mlsentinel-0.1.7.dev5-py3-none-any.whl
Algorithm Hash digest
SHA256 15f27a6d62845f19c96d9b383a37612198dff9f0901de1c348e352c563f7ce6e
MD5 0c9155136ad2e3e38607c4ff7274b174
BLAKE2b-256 6cf46b5379460fc23c861316759a99d07a227f4646c24f0d0ed6187f74d42ceb

See more details on using hashes here.

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