Skip to content

Conversation

@littleTT0704
Copy link
Contributor

@littleTT0704 littleTT0704 commented Oct 17, 2025

Description

While using az.compare(models, method="stacking"), I encountered the same problem as mentioned in #2359, where the weights column in the returned dataframe sums up to greater than 1.

My assumption is that scipy.optimize.minimize converts our dict-type constraints to a list of NonLinearConstraint, which over-complicates the problem in az.compare, since the sum of weights is a linear combination.
Moreover, by removing the np.concatenate operation in w_fuller and using vectorized operations, we can increase the efficiency of the optimizer.
In my extreme use case of comparing 54 models, I was able to reduce computation time by 14.3% (543s -> 465s) while getting the correct weight sum (3.636 -> 1.000).

However, I was not able to synthesize some test data to capture this behavior. Although we already have some test cases that asserts sum of weights should be 1, the models are too simple to produce a failure.

Checklist

  • Follows official PR format
  • Includes new or updated tests to cover the new feature
  • Code style correct (follows pylint and black guidelines)
  • Changes are listed in changelog

📚 Documentation preview 📚: https://arviz--2492.org.readthedocs.build/en/2492/

@codecov
Copy link

codecov bot commented Oct 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.83%. Comparing base (821c126) to head (b103277).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2492      +/-   ##
==========================================
- Coverage   86.84%   86.83%   -0.02%     
==========================================
  Files         124      124              
  Lines       13031    13020      -11     
==========================================
- Hits        11317    11306      -11     
  Misses       1714     1714              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@OriolAbril OriolAbril left a comment

Choose a reason for hiding this comment

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

Looks good, thanks! I will try playing with it locally and make sure we include it in the upcoming release

@OriolAbril
Copy link
Member

also requesting more reviews to also see how to port that to arviz-stats too.

Copy link
Contributor

@aloctavodia aloctavodia left a comment

Choose a reason for hiding this comment

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

LGTM! I will add it to arviz-stats. Thanks @littleTT0704

Copy link
Member

@jordandeklerk jordandeklerk left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for catching this!

@aloctavodia aloctavodia merged commit 495f709 into arviz-devs:main Oct 21, 2025
12 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.

4 participants