deephyper.ensemble.selector.OnlineSelector#
- class deephyper.ensemble.selector.OnlineSelector(y: ndarray, selector: Selector, ensemble: EnsemblePredictor, load_predictor_func: Callable)[source]#
Bases:
CallbackThis class performs ensemble selection after each hyperparameter optimization job completion.
The
run-function passed to theEvaluatorshould 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 inyused to score the selection):def run(job): ... return { "objective": objective, "online_selector": {"y_pred": y_pred, "y_pred_idx": idx}, }
the
y_predandy_pred_idxhave 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
Evaluatorused 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 when the evaluator is being closed.
Called each time a local
Jobhas been gathered by the Evaluator.Called after local
Jobhave been gathered for each remoteJobthat is done.Called after gathering jobs.
Called each time a
Jobis created by theEvaluator.Attributes
The ensemble with its weights.
List of
job.idcorresponding 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_predictorsfrom theselector.the weights of selected predictors.
- property ensemble#
The ensemble with its weights.
It will provide the
ensemblewith adapted.predictorsand.weightsfrom the latest selection.
- on_close()#
Called when the evaluator is being closed.
- on_done(job)[source]#
Called each time a local
Jobhas been gathered by the Evaluator.- Parameters:
job (Job) – The completed job.
- on_done_other(job)[source]#
Called after local
Jobhave been gathered for each remoteJobthat is done.- Parameters:
job (Job) – The completed Job.
- on_launch(job: Job)#
Called each time a
Jobis created by theEvaluator.- Parameters:
job (Job) – The created job.
- selected_predictors_indexes: List[int]#
the list of indexes of the first dimension of
y_predictorsfrom theselector.
- property selected_predictors_job_ids: List[str]#
List of
job.idcorresponding to the selected set of predictors.
- y_predictors: List[MaskedArray]#
the list of received predictions mapped to the same shape as
y.