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

Decouple pypesto.ensemble.ensemble.Ensemble from pypesto.predict.amici_predictor.AmiciPredictor #1294

Open
dweindl opened this issue Jan 25, 2024 · 1 comment
Labels
AMICI ensembles Related to parameter ensembles

Comments

@dweindl
Copy link
Member

dweindl commented Jan 25, 2024

Currently, pypesto.ensemble.ensemble.Ensemble.predict is annotated to take a predictor: Callable. However, it assumes this to be an AmiciPredictor (or at least to have an amici_objective: AmiciObjective attribute), .e.g., here:

parameter_ids_objective = predictor.amici_objective.x_names

I don't think this is ideal. This makes it unnecessarily cumbersome to create a custom predictor, which should just be some callable that takes a parameter vector and parameter IDs and produces a PredictionResult, or an EnsemblePrediction.

I'd propose:

  • Moving the functionality from pypesto.ensemble.ensemble.Ensemble._map_parameters_by_objective to the predictor
    • This gets rid of the AmiciPredictor dependency
    • However, AmiciPredictor.__call__ will then need the parameter IDs along with the parameter values. Breaking change.
    • Changing predictor: Callable to predictor: Callable[[Sequence], PredictionResult] (and respecting that)
  • Consider removing pypesto.ensemble.ensemble.Ensemble.predict altogether, and rather offer that same functionality via
    WhateverPredictor.predict(ensemble: pypesto.ensemble.ensemble.Ensemble, ...). This seems more appropriate, since different predictors might want to offer different arguments.
  • To facilitate parallelization without much reimplementation for every Predictor, it might make sense to introduce a Predictor base class that implements the respective functionality that's currently included in pypesto.ensemble.ensemble.Ensemble.predict .
@dweindl dweindl added ensembles Related to parameter ensembles AMICI labels Jan 25, 2024
@dweindl dweindl assigned dweindl and unassigned dweindl Apr 3, 2024
@dweindl
Copy link
Member Author

dweindl commented Apr 3, 2024

I think, before working on this, we'll need to discuss the desired ensemble functionality in pypesto.

The current ensemble prediction setup is 100% tailored to AMICI

class PredictionResult:
"""
Light-weight wrapper around prediction from pyPESTO made by an AMICI model.

class PredictionConditionResult:
"""
Light-weight wrapper for the prediction of one simulation condition.
It should provide a common api how amici predictions should look like in
pyPESTO.
"""

Can we / do we want to generalize that? If not, I would suggest to rename those objects to something like AmiciPredictionResult/AmiciPredictionConditionResult to make it very clear that they are only intended to work with AmiciObjective, AmiciPredictor, ...

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

No branches or pull requests

1 participant