Typed inputs, straight from your data.
MLschema reads a pandas DataFrame and returns a validated, JSON-serialisable list of fields. Each field carries a kind, a label, nullability and the backend target the model expects.
import pandas as pd
from mlschema import infer_schema
df = pd.DataFrame( { "score": [98.5, 86.0, 91.0], "role": pd.Categorical(["engineer", "engineer", "scientist"]), "active": [True, False, True], })
fields = infer_schema(df)[ { "label": "score", "required": true, "mappedTo": "score", "kind": "number", "step": 0.1 }, { "label": "role", "required": true, "mappedTo": "role", "kind": "category", "options": ["engineer", "scientist"] }, { "label": "active", "required": true, "mappedTo": "active", "kind": "boolean" }]Every field is checked against a strict Pydantic model before it is returned. Constraints that contradict each other, unknown attributes and unknown kinds fail during inference instead of reaching your interface.
Find your path
Section titled “Find your path”
Infer a first schema
Shape a DataFrame, call
infer_schema, and read the result.
Know the field kinds
Seven built-in kinds, how each is detected, and what it accepts.
Reach the model
mappedTo targets, one-hot groups, and positional feature vectors.
Refine the result
Labels, bounds, defaults and units, validated with the rest.
Add your own rules
Builders for existing kinds and kind() for new ones.
Render a form
Pass the fields to MLForm and submit the values the model expects.
MLschema is open source under the MIT license and part of eshkra. Install it from PyPI, try it in the playground, or read the source on GitHub.
