biogeme.bayesian_estimation.html_output module

Generate an HTML report from a Bayesian results summary.

This module generates HTML reports exclusively from BayesianResultsSummary, without requiring posterior draws or access to NetCDF files. All diagnostics included in the report must therefore already be stored in the summary object.

Michel Bierlaire Mon Oct 20 2025, 19:27:28

exception biogeme.bayesian_estimation.html_output.EmptyListOfParameters[source]

Bases: BiogemeError

biogeme.bayesian_estimation.html_output.format_real_number(value)[source]

Format a real number for inclusion in an HTML table.

Parameters:

value (float) – Number to format.

Return type:

str

Returns:

A short string representation (currently using .3g formatting).

biogeme.bayesian_estimation.html_output.generate_html_file(estimation_results, filename, overwrite=False)[source]

Generate an HTML file with the estimation results

Parameters:
  • estimation_results (BayesianResultsSummary) – estimation results

  • filename (str) – name of the file

  • overwrite (bool) – if True and the file exists, it is overwritten

Return type:

None

biogeme.bayesian_estimation.html_output.generate_html_file_from_results(estimation_results, filename, identification_threshold, overwrite=False)[source]

Generate an HTML report from full Bayesian results.

Diagnostic figures and identification diagnostics are first generated from the full BayesianResults object, which still contains the posterior draws. The results are then converted into a lightweight BayesianResultsSummary, and the HTML report is generated from that summary object.

Parameters:
  • estimation_results (BayesianResults) – Full Bayesian estimation results.

  • filename (str) – Name of the HTML file.

  • identification_threshold (float) – Numerical threshold used by the Bayesian identification diagnostics. It follows the same convention as the maximum-likelihood identification threshold: smaller values require stronger numerical evidence before a weak-identification direction is reported.

  • overwrite (bool) – If True and the file exists, it is overwritten.

Return type:

None

biogeme.bayesian_estimation.html_output.generate_html_simulated_data(estimation_results)[source]
Return type:

str

Parameters:

estimation_results (BayesianResultsSummary)

biogeme.bayesian_estimation.html_output.generate_one_row(description, value)[source]

Generate a single HTML table row with a description/value pair.

Parameters:
  • description (str) – Label shown in the left column.

  • value (str) – Value shown in the right column.

Return type:

str

Returns:

HTML code for one <tr> row.

biogeme.bayesian_estimation.html_output.get_html_arviz_diagnostics(estimation_results, html_filename, var_names=None)[source]

Generate an HTML snippet embedding pre-rendered diagnostic figures.

The figures must already have been generated elsewhere and referenced in the summary object. This function only embeds them in the HTML report.

Parameters:
  • estimation_results (BayesianResultsSummary) – Bayesian results summary.

  • html_filename (str) – Target HTML filename.

  • var_names (list[str] | None) – Unused, kept for API compatibility.

Return type:

str

Returns:

HTML snippet containing embedded diagnostic figures, or an empty string if no figure references are available.

biogeme.bayesian_estimation.html_output.get_html_arviz_reproduction_instructions(estimation_results, html_filename, var_names=None)[source]

Generate HTML instructions for producing additional ArviZ diagnostics.

The report embeds the diagnostic figures generated automatically during the estimation. Additional ArviZ figures can be produced by reloading the Bayesian results file, which contains the posterior draws.

Parameters:
  • estimation_results (BayesianResultsSummary) – Bayesian results summary.

  • html_filename (str) – Target HTML filename.

  • var_names (list[str] | None) – Optional list of variables to include in the examples.

Return type:

str

Returns:

HTML snippet explaining how to generate additional diagnostics.

biogeme.bayesian_estimation.html_output.get_html_estimated_parameters(estimation_results, estimated_parameters=True, renaming_parameters=None, sort_by_name=False)[source]

Get the estimated parameters coded in HTML

Parameters:
  • estimation_results (BayesianResultsSummary) – estimation results.

  • estimated_parameters (bool) – if True, only the estimated parameters are generated. If False, only the other variables are generated.

  • renaming_parameters (dict[str, str] | None) – a dict that suggests new names for some or all parameters.

  • sort_by_name (bool) – if True, parameters are sorted alphabetically by name.

Return type:

str

Returns:

HTML code

Prepare the footer for the HTML file, containing comments and the version of Biogeme.

Return type:

str

biogeme.bayesian_estimation.html_output.get_html_general_statistics(estimation_results)[source]

Get the general statistics coded in HTML

Return type:

str

Returns:

HTML code

Parameters:

estimation_results (BayesianResultsSummary)

biogeme.bayesian_estimation.html_output.get_html_header(estimation_results)[source]

Prepare the header for the HTML file, containing comments and the version of Biogeme.

Return type:

str

Returns:

string containing the header.

Parameters:

estimation_results (BayesianResultsSummary)

biogeme.bayesian_estimation.html_output.get_html_identification_diagnostics(estimation_results)[source]

Generate an HTML section reporting stored identification diagnostics.

The diagnostics must already have been computed and stored in the summary object.

Parameters:

estimation_results (BayesianResultsSummary) – Bayesian results summary.

Return type:

str

Returns:

HTML code for the identification diagnostics section, or an empty string if unavailable.

biogeme.bayesian_estimation.html_output.get_html_one_parameter(estimation_results, parameter_number, parameter_name, display_name)[source]

Generate the HTML code for one row of the table of the estimated parameters.

Parameters:
  • estimation_results (BayesianResultsSummary) – estimation results.

  • parameter_number (int) – index of the parameter

  • parameter_name (str) – real key of the parameter in the stored summary.

  • display_name (str) – name to display in the table.

Return type:

str

Returns:

HTML code for the row

biogeme.bayesian_estimation.html_output.get_html_preamble(estimation_results, file_name)[source]

Generates the first part of the HTML, with the preamble information.

Parameters:
  • estimation_results (BayesianResultsSummary) – estimation results

  • file_name (str) – name of the HTML file (used only for reporting)

Return type:

str

Returns:

HTML code