.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/sampling/compare.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_sampling_compare.py: Compare parameters ================== Function to compare estimated parameters with true parameters. :author: Michel Bierlaire :date: Wed Nov 1 18:07:08 2023 .. GENERATED FROM PYTHON SOURCE LINES 11-16 .. code-block:: default import pandas as pd from biogeme.results import bioResults from true_parameters import true_parameters .. GENERATED FROM PYTHON SOURCE LINES 17-46 .. code-block:: default def compare(estimated_parameters: bioResults) -> tuple[pd.DataFrame, str]: """Compare estimated and true parameters :param estimated_parameters: estimation results """ non_estimated = [] data = [] for name, value in true_parameters.items(): try: est_value = estimated_parameters.at[name, 'Value'] std_err = estimated_parameters.at[name, 'Rob. Std err'] t_test = (value - est_value) / std_err # Append the data to the list instead of printing data.append( { 'Name': name, 'True Value': value, 'Estimated Value': est_value, 'T-Test': t_test, } ) except KeyError: non_estimated.append(name) # Convert the list of dictionaries to a DataFrame msg = f'Parameters not estimated: {non_estimated}' if non_estimated else '' df = pd.DataFrame(data) return df, msg .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_sampling_compare.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: compare.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: compare.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_