Skip to content
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

Add Campaign.posterior_stats #504

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Conversation

Scienfitz
Copy link
Collaborator

@Scienfitz Scienfitz commented Mar 6, 2025

  • Adds a convenience function posterior_stats to the Campaign, returning a data frame of statistics about the target predictions
  • Adds a test for this
  • Mentions it in the user guide
  • Changed the default acqf in conftest (which was still the non-log version)

Currently, for desirability objectives it is hardcoded that the statistics are for a single target called "Desirability", consistent with what transform does. Once posterior transforms are available, this logic needs to be adapted and it is expected that there is a flag in DesirabilityObjective that decides between scalarization or posterior_transforms. The latter case can then be treated exactly like all other targets.

@Scienfitz Scienfitz added the new feature New functionality label Mar 6, 2025
@Scienfitz Scienfitz self-assigned this Mar 6, 2025
@Scienfitz Scienfitz force-pushed the feature/posterior_statistics branch 2 times, most recently from bf9d6d4 to 1302816 Compare March 10, 2025 17:37
@Scienfitz Scienfitz changed the title Add Campaign.posterior_statistics Add Campaign.posterior_stats Mar 10, 2025
Copy link
Collaborator

@AdrianSosic AdrianSosic left a comment

Choose a reason for hiding this comment

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

Hi @Scienfitz, here my comments regarding the code. Will now also have a quick look at the docs/tests

Copy link
Collaborator

@AdrianSosic AdrianSosic left a comment

Choose a reason for hiding this comment

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

I think this is all. Thx for the PR, looking good! Nice to have this high-level access now! ⭐

@@ -125,7 +125,47 @@ far. This is done by setting the following Boolean flags:
`pending_experiments` can be recommended (see [asynchronous
workflows](PENDING_EXPERIMENTS)).

### Caching of recommendations
### Prediction Statistics
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd say let's use Posterior Statistics. For once it's the correct term and consistent with the method name, and second I think that "prediction statistics" is technically really wrong, because a prediction cannot have a statistic (since it's already a realization)

Suggested change
### Prediction Statistics
### Posterior Statistics

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

main motivation in the heading here is not the technically correct term (the method is named technically correct)

but there is an argument to have about what unexperienced users are looking for, and there statistics about the predictions imo is something most people know or can phrase even without deeper technical knowledge, while the posterior reaches much less people

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

another opinion on this renaming might enable us to make a quick decision @AVHopp

  • Prediction Statistics
  • Target Statistics
  • Posterior Statistics
  • Predictive Statistics
  • anything better?

again, my problem with Posterior Statistics is that I don't think many unexperienced people will associate this with the feature they are looking for

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd be fine with Predictive Statistics

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed

Copy link
Collaborator

Choose a reason for hiding this comment

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

One more general comment: Just like we have Campaign.get_posterior fetch the object from the underlying Recommender, wouldn't it actually make sense to implement the core logic of posterior_stats in the BayesianRecommender class and then make Campaign just reuse it? That way, it would also become available at the recommender level, analogous to BayesianRecommender.posterior

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@AdrianSosic
Can you point me to where is BayesianRecommender.posterior or did you get this confused? Or is it because of the Adapter? As far as I can see its only part of surrogates

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I mixed up a few things. Campaign.get_posterior fetches the surrogate via the recommender and then evaluates it. So similarly, Campaign.posterior_stats could again fetch the surrogate from the recommender and then just call the posterior_stats there (which would contain the core logic you've implemented)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok I pushed a proposal commit for that, seems to work
gets rid of a workaround for PosteriorList because the composite just calls the single surrogates, which however are initialized with single-objectives and a posterior list doesnt appear anywhere

# Assert no NaN's present
assert not stats.isna().any().any()

# Assert correct error for unsupported statistics
Copy link
Collaborator

Choose a reason for hiding this comment

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

Basically analogous to what you suggested in the cardinality PR. From here onwards, the tests are actually not really related to the actual input and only test for errors. Wouldn't it make sense to split it up and thereby separate valid and invalid cases into two isolated tests?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i) the cardinality PR in the end did not separate the tests but amde one big test
ii) i would have to rewrite the entire long parameterization (main motivation to just append the invalid tests tot his one)

Copy link
Collaborator

Choose a reason for hiding this comment

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

ii) but if I'm not mistaken, the test don't need anything specific from that parametrization. So in that sense, the validations are also executed too often for no reason. If you separated the parts, the validation would not require a parameterization in the first place

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmm thats debatable, arguably its better to test all kinds of surrogates and objectives also for the invalid tests?

Also: Given that these tests are a fraction of the cost thats needed for creating the campaign and the stat computation, why even bother?

@Scienfitz Scienfitz force-pushed the feature/posterior_statistics branch from 9ed9a3a to cfbec87 Compare March 11, 2025 14:22
@Scienfitz Scienfitz force-pushed the feature/posterior_statistics branch from c7e9fb6 to 09dbfb2 Compare March 12, 2025 15:52
@Scienfitz Scienfitz force-pushed the feature/posterior_statistics branch from e43d88c to 61703ae Compare March 12, 2025 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants