Model card (autodoc)¶
Assembles the canonical multi-section ModelCard JSON consumed by the backend
DOCX / HTML / PDF renderer. See the
Evaluation & trust guide.
build_model_card¶
build_model_card ¶
build_model_card(
profile: "ProfilingResult",
*,
fitted: Any | None = None,
dataset_meta: Any | None = None,
diagnostics: Any | None = None,
drift_report: "PSIResult | None" = None,
leakage_report: "LeakageReport | None" = None,
trust_summary: "TrustSummary | None" = None,
usecase: Any | None = None,
annotations: Mapping[str, CardAnnotation] | None = None
) -> ModelCard
Assemble a :class:ModelCard from a fitted :class:ProfilingResult.
Pure science layer — no I/O, no caching, no backend specifics.
Sections whose underlying artefact is missing surface as
{"available": False} so the renderer in
backend_changes_for_ui.md §5.5 can hide the row gracefully.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile
|
'ProfilingResult'
|
The :class: |
required |
fitted
|
Any | None
|
Optional deployable artefact — a |
None
|
dataset_meta
|
Any | None
|
Optional dataset metadata satisfying the
:class: |
None
|
diagnostics
|
Any | None
|
Optional diagnostics payload carrying the Optuna leaderboard
and the list of families tried (any object exposing
|
None
|
drift_report
|
'PSIResult | None'
|
Optional :class: |
None
|
leakage_report
|
'LeakageReport | None'
|
Optional :class: |
None
|
trust_summary
|
'TrustSummary | None'
|
Optional :class: |
None
|
usecase
|
Any | None
|
Optional governance metadata satisfying the
:class: |
None
|
annotations
|
Mapping[str, CardAnnotation] | None
|
AI-written text the host attaches, keyed |
None
|
Returns:
| Type | Description |
|---|---|
ModelCard
|
The canonical Model Card intermediate JSON (eleven content
sections enumerated by :data: |
ModelCard¶
ModelCard
dataclass
¶
ModelCard(
cover: dict[str, Any] = dict(),
executive_summary: str = "",
executive_summary_label: str | None = None,
overview: dict[str, Any] = dict(),
data_quality: dict[str, Any] = dict(),
feature_engineering: dict[str, Any] = dict(),
algorithm_selection: dict[str, Any] = dict(),
final_pipeline: dict[str, Any] = dict(),
scores: dict[str, Any] = dict(),
interpretability: dict[str, Any] = dict(),
drift: dict[str, Any] = dict(),
assumptions_limitations: dict[str, Any] = dict(),
monitoring_plan: dict[str, Any] = dict(),
governance_signoff: dict[str, Any] = dict(),
recommendations: list[str] = list(),
ai_written: list[dict[str, str]] = list(),
figures: list[dict[str, Any]] = list(),
trust_summary: dict[str, Any] | None = None,
provenance: dict[str, Any] = dict(),
schema_version: int = AUTODOC_SCHEMA_VERSION,
)
Canonical Model Card intermediate JSON.
Holds the content sections enumerated by
:data:MODEL_CARD_SECTIONS (cover, executive summary, overview,
data quality, feature engineering, algorithm selection, final
pipeline, scores, interpretability, drift, assumptions &
limitations, monitoring plan, governance & sign-off,
recommendations) plus three scaffolding fields
(:attr:trust_summary, :attr:provenance, :attr:schema_version).
Section order mirrors the AutoDoc template specification in
backend_changes_for_ui.md §17 — the renderer iterates
:data:MODEL_CARD_SECTIONS to lay sections out deterministically.
Every nested value is JSON-clean (plain dict / list /
str / int / float / bool / None) so the whole
instance round-trips through :func:json.dumps without custom
encoders.
Attributes:
| Name | Type | Description |
|---|---|---|
cover |
dict[str, Any]
|
|
executive_summary |
str
|
Plain-English one-paragraph narrative — the host's
|
executive_summary_label |
str | None
|
The annotation's label (e.g. |
overview |
dict[str, Any]
|
|
data_quality |
dict[str, Any]
|
EDA alerts + missingness + duplicates + leakage findings. |
feature_engineering |
dict[str, Any]
|
|
algorithm_selection |
dict[str, Any]
|
|
final_pipeline |
dict[str, Any]
|
|
scores |
dict[str, Any]
|
|
interpretability |
dict[str, Any]
|
|
drift |
dict[str, Any]
|
|
assumptions_limitations |
dict[str, Any]
|
|
monitoring_plan |
dict[str, Any]
|
|
governance_signoff |
dict[str, Any]
|
|
recommendations |
list[str]
|
Plain-English warnings — one entry per high-severity leakage finding, fairness flag, red trust tile, or significant drift. |
ai_written |
list[dict[str, str]]
|
One |
figures |
list[dict[str, Any]]
|
Embedded charts attached by the backend renderer — an ordered
list of |
trust_summary |
dict[str, Any] | None
|
Optional embedded :class: |
provenance |
dict[str, Any]
|
Library / artefact / dataset versions so the regulator can reconstruct exactly which code produced the doc. |
schema_version |
int
|
Bumped on any wire-shape change (mirrors
:data: |
CardAnnotation¶
AI-written text the host attaches to a card, keyed "explain.narration" /
"explain.fields". See AI-written narration.
CardAnnotation
dataclass
¶
AI-written text the host attaches to a model card, and the label every reader sees.
Section ordering¶
MODEL_CARD_SECTIONS is the canonical, deterministic ordering the renderer
iterates across HTML / DOCX / PDF.
MODEL_CARD_SECTIONS
module-attribute
¶
MODEL_CARD_SECTIONS: tuple[str, ...] = (
"cover",
"executive_summary",
"overview",
"data_quality",
"feature_engineering",
"algorithm_selection",
"final_pipeline",
"scores",
"interpretability",
"drift",
"assumptions_limitations",
"monitoring_plan",
"governance_signoff",
"recommendations",
)
Canonical ordering of the Model Card sections — matches the AutoDoc
template structure in backend_changes_for_ui.md §17. The renderer
iterates this tuple to keep section ordering deterministic across HTML /
DOCX / PDF outputs.
The three governance sections (assumptions_limitations /
monitoring_plan / governance_signoff) sit just before
recommendations so the document reads evidence → caveats →
monitoring → sign-off → actions.
Backend-supplied input protocols¶
Duck-typed contracts build_model_card reads off its optional
dataset_meta / use_case_governance arguments — the backend's dataclasses,
SQLite rows, or plain dicts all satisfy them.
DatasetMetaLike ¶
Bases: Protocol
Minimum surface :func:build_model_card reads off dataset_meta.
The backend's DatasetMeta dataclass / SQLite row / plain dict
all satisfy this contract via attribute access or mapping-style
lookup — :func:parleml_mli.autodoc._sections._get normalises both.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Dataset display name ( |
version |
str | None
|
Optional dataset version (catalog |
n_rows |
int
|
Total row count of the training matrix. |
n_columns |
int
|
Total column count of the raw (pre-FE) frame. |
target |
str | None
|
Target column name. |
target_rate |
float | None
|
Positive-class rate (binary) / mean (regression) /
most-frequent rate (multiclass). |
fingerprint |
str | None
|
Stable content / schema hash for reproducibility. |
UseCaseGovernanceLike ¶
Bases: Protocol
Minimum surface :func:build_model_card reads off usecase.
Mirrors the /api/usecases payload documented in
backend_changes_for_ui.md §3.0. All fields optional; the
builder degrades to a generic "no use-case bound" cover when
usecase is None.
A use case's stage and risk level are not read: they describe the use case, not a model built in it. Nor is a typed list of sensitive attributes — the card's are the ones the run's fairness report measured.