Skip to content

New functions for posterior evaluation #142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Wenda-Lou
Copy link

This PR introduces two helper modules for evaluating the quality of MCMC posterior distributions from ECM (Equivalent Circuit Model) fits and integrating those evaluations into the AutoEIS pipeline.

New Modules
1. evaluate_posterior_distribution.py

  • Implements a scoring function for MCMC posterior samples.
  • Evaluates each component using:
  • R² from a Q-Q plot against a normal distribution.
  • Skewness of the sample.
  • Number of peaks in the KDE-estimated distribution.
  • Optionally saves KDE plots and histograms for each parameter.
  • Returns a functionality score and list of problematic parameters.

2. update_circuits_info.py

  • Applies the scoring function to each InferenceResult in a circuit list.
  • Updates the circuits_df DataFrame with:
  • Posterior scores.
  • Bad parameter flags.
  • Sorted ranking based on score and parameter quality.
  • Computes and appends fitness metrics using AutoEIS core tools.

These tools enhance AutoEIS by:

  • Quantitatively assessing posterior reliability.
  • Flagging multi-peak, skewed, or poorly fitted parameters.
  • Enabling better model selection via posterior-informed ranking.

These 2 files are used as helper functions for evaluating the posterior distribution of ECM and EIS data. The "evaluate_posterior_distribution" defines functions that scores MCMC posterior distributions of each component in the ECM. It gives a functionality score for each component based on R^2 from a QQ-plot to a normal distribution, skewness of the sample and the number of peaks appeared on the distribution.

The script "update_circuits_info" complements "evaluate_posterior_distribution" by applying the posterior quality evaluation to a list of AutoEIS inference results and updating a circuits_df DataFrame accordingly.
@Wenda-Lou Wenda-Lou changed the title 2 Helper functions for posterior evaluation New functions for posterior evaluation Jun 19, 2025
@ma-sadeghi
Copy link
Collaborator

ma-sadeghi commented Jun 19, 2025

Hi @Wenda-Lou, thanks for the PR! You can find my comments under "Files changed". I'm still trying understand the PR better. I'll give it a try tonight or tomorrow and will get back to you.

@Wenda-Lou
Copy link
Author

Thank you for your feedback. I developed this module alongside Zhecheng Yin, another undergraduate student. He should have started a separate PR outlining the basic workflow of this module. It might be easier to review the code in conjunction with the workflow outlined in his PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants