Inspecting inference results#
This example notebook will show how to load the results after an inference to inspect the properties. For this, we can use the functionalities in the InferenceResult class.
NOTE: This notebook assumes you have ran a jester inference and can point to a results.h5 file by adjusting this notebook. If you have not done this, you can run the chiEFT likelihood with the SMC sampler easily on a laptop. We will use that inference result for the demonstration here.
[1]:
from jesterTOV.inference.result import InferenceResult
[2]:
results_path = "../../../examples/inference/smc_random_walk/chiEFT/outdir/results.h5"
result = InferenceResult.load(results_path)
print("Available keys:")
for key, value in vars(result).items():
print(f"{key}")
[INFO] jester: Loading inference results from ../../../examples/inference/smc_random_walk/chiEFT/outdir/results.h5
[INFO] jester: Successfully loaded blackjax_smc_rw results
Available keys:
sampler_type
posterior
metadata
histories
fixed_params
[3]:
sampler_type = result.sampler_type
print(f"sampler_type: {sampler_type}")
posterior = result.posterior
print("posterior keys")
print(list(posterior.keys()))
metadata = result.metadata
print("metadata keys")
print(list(metadata.keys()))
# These are the histories of the metrics that are tracked during the inference
histories = result.histories
print(f"\nhistories: {histories}")
fixed_params = result.fixed_params
print(f"\nfixed_params: {fixed_params}")
sampler_type: blackjax_smc_rw
posterior keys
['E_sat', 'E_sym', 'K_sat', 'K_sym', 'L_sym', 'Q_sat', 'Q_sym', 'Z_sat', 'Z_sym', 'cs2_CSE_0', 'cs2_CSE_1', 'cs2_CSE_2', 'cs2_CSE_3', 'cs2_CSE_4', 'cs2_CSE_5', 'cs2_CSE_6', 'cs2_CSE_7', 'cs2_CSE_8', 'n_CSE_0_u', 'n_CSE_1_u', 'n_CSE_2_u', 'n_CSE_3_u', 'n_CSE_4_u', 'n_CSE_5_u', 'n_CSE_6_u', 'n_CSE_7_u', 'nbreak', 'Lambdas_EOS', 'cs2', 'e', 'masses_EOS', 'n', 'n_TOV', 'p', 'radii_EOS', '_sampler_specific', 'log_prob']
metadata keys
['config_json', 'annealing_steps', 'creation_timestamp', 'final_ess', 'final_ess_percent', 'fixed_params', 'kernel_type', 'logZ', 'logZ_err', 'mean_acceptance', 'mean_ess', 'min_ess', 'n_mcmc_steps', 'n_particles', 'n_samples', 'parameter_names', 'sampler', 'sampling_time', 'seed', 'target_ess']
histories: {'acceptance_history': array([0.5309 , 0.53073545, 0.53777032, 0.54399167, 0.53440824,
0.54470018, 0.53606017, 0.53249006, 0.52549488, 0.52222282,
0.52849188, 0.52766487, 0.53030358, 0.52324858]), 'ess_history': array([0.98863491, 0.99563471, 0.99846088, 0.99962016, 1. ,
0.91933081, 0.93660557, 0.95136335, 0.96040997, 0.96982907,
0.97403149, 0.97722058, 0.98010417, 0.99572858]), 'log_evidence_history': array([-0.01667338, -0.02296372, -0.02492735, -0.02536324, -0.02536324,
-0.37465495, -0.63846425, -0.83897929, -1.00144874, -1.13179534,
-1.24482355, -1.34410429, -1.43345886, -1.4719266 ]), 'tempering_param_history': array([5.83924020e-11, 1.18049570e-10, 1.94830818e-10, 2.97461611e-10,
4.36159553e-10, 8.77990727e-02, 1.75294419e-01, 2.64565375e-01,
3.60310130e-01, 4.65103075e-01, 5.88935108e-01, 7.34955474e-01,
9.12061643e-01, 1.00000000e+00])}
fixed_params: {}
[ ]: