compileml.export

export_cobol

def export_cobol(artifact: dict, *, program_id: str = 'CMLSCORE', driver_rows: list | None = None, explain: bool = False, top_k: int | None = None) -> str

from compileml.export import export_cobol

Render the artifact's score, band and calibrated PD as a COBOL program.

The generated program reads features from WORKING-STORAGE (integration point: MOVE caller values in, or adapt to a LINKAGE SECTION), then leaves F-LATENT-INT (display-scale score), FINAL-BAND and F-PD-PPM (calibrated PD, parts per million) populated.

With driver_rows (a list of feature rows), the program becomes a parity harness instead: it scores every row and DISPLAYs latent_int band pd_ppm one row per line — compile it, run it, and diff the output against the Python runtime. CI does exactly that under GnuCOBOL.

With explain=True the program also computes exact attribution and leaves the top top_k adverse and favorable reasons in REASON-NEG-CODE(i) / REASON-NEG-IMPACT(i) and REASON-POS-CODE(i) / REASON-POS-IMPACT(i), with REASON-NEG-COUNT and REASON-POS-COUNT saying how many are filled. Codes and display-scale integer impacts match decide(..., explain=True) exactly; message text stays with the institution's letter templates. top_k defaults to the artifact's own. The driver harness then also prints each reason.

Raises: ExportError: EXPLAIN_NOT_EXACT or REASON_CODE_NOT_ASCII — see :class:`ExportError`.

Parameters#

NameTypeDefaultKind
artifactdictrequiredpositional
program_idstr'CMLSCORE'keyword-only
driver_rowslist | NoneNonekeyword-only
explainboolFalsekeyword-only
top_kint | NoneNonekeyword-only

Returns#

str

Raises#

  • ExportError
  • ValueError

Read from the function body and the private helpers it calls, not inferred. A function that raises nothing has no section here.

Example#

python
from compileml.export import export_cobol
 
cob = export_cobol(artifact, program_id="SCORER")

Worked example: export_cobol →