Skip to content

Conversation

abelaba
Copy link
Collaborator

@abelaba abelaba commented Aug 24, 2025

This PR updates the RatioEstimator class to be a subclass of ConditionalEstimator. It also removes the RatioEstimatorBuilder and VectorFieldEstimatorBuilder protocols, as these protocols can be represented using the DensityEstimatorBuilder protocol.

@abelaba abelaba marked this pull request as draft August 24, 2025 00:11
@abelaba abelaba marked this pull request as ready for review August 24, 2025 20:02
Copy link

codecov bot commented Aug 24, 2025

Codecov Report

❌ Patch coverage is 94.11765% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@0c75b9c). Learn more about missing BASE report.
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
sbi/diagnostics/misspecification.py 50.00% 1 Missing ⚠️
sbi/neural_nets/ratio_estimators.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1652   +/-   ##
=======================================
  Coverage        ?   82.56%           
=======================================
  Files           ?      134           
  Lines           ?    11140           
  Branches        ?        0           
=======================================
  Hits            ?     9198           
  Misses          ?     1942           
  Partials        ?        0           
Flag Coverage Δ
unittests 82.56% <94.11%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sbi/inference/trainers/base.py 93.52% <100.00%> (ø)
sbi/inference/trainers/nle/mnle.py 95.65% <100.00%> (ø)
sbi/inference/trainers/nle/nle_a.py 100.00% <100.00%> (ø)
sbi/inference/trainers/nle/nle_base.py 97.82% <100.00%> (ø)
sbi/inference/trainers/npe/mnpe.py 95.65% <100.00%> (ø)
sbi/inference/trainers/npe/npe_a.py 63.91% <ø> (ø)
sbi/inference/trainers/npe/npe_b.py 100.00% <100.00%> (ø)
sbi/inference/trainers/npe/npe_base.py 94.77% <100.00%> (ø)
sbi/inference/trainers/npe/npe_c.py 73.33% <ø> (ø)
sbi/inference/trainers/nre/bnre.py 46.66% <100.00%> (ø)
... and 10 more

Copy link
Contributor

@janfb janfb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a great refactoring @abelaba! 👏
if we reconcile all the protocols into one then this should not be called DensityEstimatorBuilder because it also concerns functions that build ratio estimators or vector field estimators. I suggest to do a renaming into ConditionalEstimatorBuilder.

this is the only required change for now, I will do another full review afterwards - thanks! 🙏

Copy link
Contributor

@janfb janfb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too small things to fix, otherwise good to go 🚀

@abelaba abelaba changed the title Update ratio estimator Refactor RatioEstimator to subclass ConditionalEstimator and remove redundant builder protocols Sep 1, 2025
Copy link
Contributor

@janfb janfb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@janfb janfb merged commit 333427f into sbi-dev:main Sep 2, 2025
9 checks passed
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