flexs.baselines.models.adaptive_ensemble

Defines the AdaptiveEnsemble model.

class flexs.baselines.models.adaptive_ensemble.AdaptiveEnsemble(models, combine_with='sum', adapt_weights_with='r2_weights', adaptive_val_size=0.2)[source]

Bases: flexs.model.Model

Ensemble class that weights individual model predictions adaptively, according to some reweighting function.

train(sequences, labels)[source]

Train each model in the ensemble and then adaptively reweight them according to adapt_weights_with.

Parameters
  • sequences (Union[List[str], ndarray]) – Training sequences.

  • lables – Training sequence labels.

flexs.baselines.models.adaptive_ensemble.r2_weights(model_preds, labels)[source]
Parameters
  • model_preds (ndarray) – A numpy array of shape (num_models, num_samples) containing model predictions.

  • labels (ndarray) – A numpy array of true labels.

Return type

ndarray

Returns

A numpy array of shape (num_models,) containing $r^2$ scores for models.