Skip to content

html_report

Return the model report as one self-contained HTML page: everything needed to judge how well the model fits, its structure, its pruning, every rating factor and interaction, and the review flags, in tabs led by a one-screen overview.

This is report_html(pricing_report(...)): it takes the same parameters as pricing_report. The page holds no scripts and loads nothing from the network, so it opens offline, in a sandboxed viewer such as MLflow's artifact view, and prints. To keep the data as well as the page, call pricing_report and log the dictionary too: the page can be rebuilt from it at any time with report_html.

See Model report for the tabs of the page.

Note

The model prediction results will be correct only if the X parameter with feature values contains all the features used in the model. For a polars DataFrame or LazyFrame, the features are matched by name: extra columns are ignored and the order of the columns does not matter (a LazyFrame collects only the columns the model needs). For other types, and for a model trained without feature names, the features must be in the same number and order as the columns provided during the training.

Method call format

html_report(X, y, *,
            sample_weight=None, exposure=None, offset=None,
            ref_measure=None,
            eval_set=None, eval_sample_weight=None, eval_exposure=None, eval_offset=None,
            labels=None,
            name=None,
            thresholds=None)

Parameters

The parameters of pricing_report.

Return value

A string: the HTML document.

Usage examples

# model: a TBoostRegressor(objective="poisson") trained with exposure="Exposure"
html = model.html_report(train_data, "ClaimCount", exposure="Exposure",
                         eval_set=(test_data, "ClaimCount"), eval_exposure="Exposure",
                         name="Motor frequency v3", thresholds={"ae_test": 0.03})
with open("freq_report.html", "w") as f:
    f.write(html)