export_sql
from compileml.export import export_sql
Render the artifact as one SQL query over table.
table must expose one float64 column per feature, named exactly as
in features.names (imputation per the artifact's missing policy is
the loader's job — SQL NULL comparisons would otherwise silently skip
branches). Returns all source columns plus raw_micro, latent_micro,
latent_int, band, and pd_ppm.
Dialects: "ansi" (GREATEST/LEAST) or "sqlite" (two-arg MAX/MIN).
With explain=True each row also carries the top top_k adverse and
favorable reasons as reason_neg_<s>_code / reason_neg_<s>_impact
and reason_pos_<s>_code / reason_pos_<s>_impact (NULL where a
slot is empty) — the codes and display-scale integer impacts
decide(..., explain=True) returns, in order. Working columns used to
compute them are prefixed cml_. top_k defaults to the artifact's
own.
Raises:
ExportError: EXPLAIN_NOT_EXACT when attribution is not exact.
Parameters#
| Name | Type | Default | Kind |
|---|---|---|---|
| artifact | dict | required | positional |
| table | str | 'features' | keyword-only |
| dialect | str | 'ansi' | keyword-only |
| explain | bool | False | keyword-only |
| top_k | int | None | None | keyword-only |
Returns#
str
Raises#
- ValueError
Read from the function body and the private helpers it calls, not inferred. A function that raises nothing has no section here.
Example#
from compileml.export import export_sql sql = export_sql(artifact, table="applications")