deephyper.ensemble.selector.OnlineSelector#
- class deephyper.ensemble.selector.OnlineSelector(y: ndarray, selector: Selector, ensemble: EnsemblePredictor, load_predictor_func: Callable)[source]#
Bases:
Callback
This class performs ensemble selection after each hyperparameter optimization job completion.
The
run
-function passed to theEvaluator
should return in its output the"online_selector"
key. This key has for value a dictionnary that includes both the"y_pred"
key (i.e., predictions of the predictor on which the selection algorithm is applied) and the"y_pred_idx"
key (i.e., indexes of the considered sampled iny
used to score the selection):def run(job): ... return { "objective": objective, "online_selector": {"y_pred": y_pred, "y_pred_idx": idx}, }
the
y_pred
andy_pred_idx
have same first dimension.Then, we can create an instance of
OnlineSelector
:from deephyper.ensemble.aggregator import MeanAggregator from deephyper.ensemble.loss import SquaredError from deephyper.ensemble.selector import GreedySelector online_selector = OnlineSelector( y=valid_y, selector=GreedySelector( loss_func=SquaredError(), aggregator=MeanAggregator(), k=20, ), )
Winally pass this callback to the
Evaluator
used for hyperparameter optimization:evaluator = Evaluator.create( run, method_kwargs={ "callbacks": [ online_selector, ], }, )
- Parameters:
y (np.ndarray) – the data to use for the selector.
selector (Selector) – the selection strategy to use.
Methods
Called each time a local
Job
has been gathered by the Evaluator.Called after local
Job
have been gathered for each remoteJob
that is done.Called each time a
Job
is created by theEvaluator
.Attributes
The ensemble with its weights.
List of
job.id
corresponding to the selected set of predictors.the data to use for the
selector
.the ensemble selection algorithm.
the list of received job.id from completed hyperparameters optimization jobs.
the list of received predictions mapped to the same shape as
y
.the list of indexes of the first dimension of
y_predictors
from theselector
.the weights of selected predictors.
- property ensemble#
The ensemble with its weights.
It will provide the
ensemble
with adapted.predictors
and.weights
from the latest selection.
- on_done(job)[source]#
Called each time a local
Job
has been gathered by the Evaluator.- Parameters:
job (Job) – The completed job.
- on_done_other(job)[source]#
Called after local
Job
have been gathered for each remoteJob
that is done.- Parameters:
job (Job) – The completed Job.
- on_launch(job)#
Called each time a
Job
is created by theEvaluator
.- Parameters:
job (Job) – The created job.
- selected_predictors_indexes: List[int]#
the list of indexes of the first dimension of
y_predictors
from theselector
.
- property selected_predictors_job_ids: List[str]#
List of
job.id
corresponding to the selected set of predictors.
- y_predictors: List[MaskedArray]#
the list of received predictions mapped to the same shape as
y
.