A Python micro-library that converts pandas DataFrames into fully-validated, front-end-ready JSON schemas
Project description
MLSchema
Automated schema inference for data‑driven organisations, grounded in proven design, built for tomorrow.
1. Executive Summary
MLSchema is a Python micro‑library that converts pandas dataframes into fully‑validated, front‑end‑ready JSON schemas. The goal: eliminate hand‑rolled form definitions, accelerate prototype‑to‑production cycles, and enforce data‑contract governance across your analytics stack.
| Metric | Outcome |
|---|---|
| Time‑to‑schema | < 150 ms on 10 k columns / 1 M rows (benchmarked on x86‑64, Python 3.13) |
| Boilerplate reduced | ≈ 90 % fewer lines of bespoke form code |
| Extensibility | Plug‑in architecture, register or swap strategies at runtime |
2. Quick Installation
For green‑field projects or CI pipelines, a single command sets up MLSchema and its dependency graph using uv:
uv add mlschema
For other package managers, refer to the dedicated Installation guide.
3. 90‑Second Onboarding
import pandas as pd
from mlschema import MLSchema
from mlschema.strategies import TextStrategy
# 1️⃣ Source your data
df = pd.read_csv("data.csv")
# 2️⃣ Spin up the orchestrator and register baseline strategies
ms = MLSchema()
ms.register(TextStrategy())
# 3️⃣ Produces a JSON schema
schema = ms.build(df)
Outcome: a JSON that your UI layer can instantly translate into dynamic forms.
4. Architectural Building Blocks
| Component | Role | Extensibility Point |
|---|---|---|
mlschema.MLSchema |
Strategy registry, validation pipeline, JSON emitter | register(), update(), unregister() |
| Field Strategies | Map pandas dtypes => form controls | Implement Strategy subclasses |
BaseField (Pydantic) |
Canonical schema blueprint | Custom Pydantic models inherit from it |
Why a Strategy Pattern?
- Single‑responsibility: Each strategy owns one field type.
- Hot‑swap: Swap implementations without touching consumer code.
- Forward compatibility: Introduce domain‑specific controls (e.g., geospatial pickers) with near‑zero refactor.
5. Feature Highlights
- Zero‑configuration defaults: Text fallback ensures graceful degradation.
- Pydantic v2 validators: Domain rules enforced at build time.
- Runtime performance: Vectorised dtype checks, no Python loops on critical paths.
- Production readiness: CI badge, semantic versioning, and zero open CVEs (September 2025).
6. Further Reading
Tradition meets innovation: MLSchema codifies time‑honoured form‑generation workflows while embracing Python’s latest language features.
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
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 mlschema-0.1.0.tar.gz.
File metadata
- Download URL: mlschema-0.1.0.tar.gz
- Upload date:
- Size: 43.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17a54a175479902c24f2f095e0c9bd263f9c9e69fd4453ee2e7214a93b1a26c0
|
|
| MD5 |
6c1eb90142a9e0c307b00fa196a0aa95
|
|
| BLAKE2b-256 |
7292999f76e5e42a3f34df332c5481dc7e042dd1e62391dee2d1d293e3b1e579
|
File details
Details for the file mlschema-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mlschema-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1e79fdbfad022034ea0fe0f4c796ab3fed5000f708ed0b5f251347b6cf8c43a
|
|
| MD5 |
72e77e0d598054bc0dfb4f5ff2f8b219
|
|
| BLAKE2b-256 |
42111335d6c0d35cf970c69787f60f6526f35490e1eaf264e1afe2d19c146721
|