MCPcopy Create free account
hub / github.com/modAL-python/modAL / DeepActiveLearner

Class DeepActiveLearner

modAL/models/learners.py:183–296  ·  view source on GitHub ↗

This class is an model of a general deep active learning algorithm. Differences to the classical ActiveLearner are: - Data is no member variable of the DeepActiveLearner class - Misses the initial add/train data methods, therefore always trains on new data - Uses dif

Source from the content-addressed store, hash-verified

181
182
183class DeepActiveLearner(BaseLearner):
184 """
185 This class is an model of a general deep active learning algorithm.
186 Differences to the classical ActiveLearner are:
187 - Data is no member variable of the DeepActiveLearner class
188 - Misses the initial add/train data methods, therefore always trains on new data
189 - Uses different interfaces to sklearn in some functions
190
191 Args:
192 estimator: The estimator to be used in the active learning loop.
193 query_strategy: Function providing the query strategy for the active learning loop,
194 for instance, modAL.uncertainty.uncertainty_sampling.
195 on_transformed: Whether to transform samples with the pipeline defined by the estimator
196 when applying the query strategy.
197 **fit_kwargs: keyword arguments.
198
199 Attributes:
200 estimator: The estimator to be used in the active learning loop.
201 query_strategy: Function providing the query strategy for the active learning loop.
202 """
203
204 def __init__(self,
205 estimator: BaseEstimator,
206 query_strategy: Callable = uncertainty_sampling,
207 on_transformed: bool = False,
208 **fit_kwargs
209 ) -> None:
210 # TODO: Check if given query strategy works for Deep Learning
211 super().__init__(estimator, query_strategy, on_transformed, **fit_kwargs)
212
213 self.estimator.initialize()
214
215 def fit(self, X: modALinput, y: modALinput, bootstrap: bool = False, **fit_kwargs) -> 'BaseLearner':
216 """
217 Interface for the fit method of the predictor. Fits the predictor to the supplied data.
218
219 Args:
220 X: The samples to be fitted.
221 y: The corresponding labels.
222 bootstrap: If true, trains the estimator on a set bootstrapped from X.
223 Useful for building Committee models with bagging.
224 **fit_kwargs: Keyword arguments to be passed to the fit method of the predictor.
225
226 Returns:
227 self
228 """
229 return self._fit_on_new(X, y, bootstrap=bootstrap, **fit_kwargs)
230
231 def teach(self, X: modALinput, y: modALinput, warm_start: bool = True, bootstrap: bool = False, **fit_kwargs) -> None:
232 """
233 Trains the predictor with the passed data (warm_start decides if params are resetted or not).
234
235 Args:
236 X: The new samples for which the labels are supplied by the expert.
237 y: Labels corresponding to the new instances in X.
238 warm_start: If False, the model parameters are resetted and the training starts from zero,
239 otherwise the pre trained model is kept and further trained.
240 bootstrap: If True, training is done on a bootstrapped dataset. Useful for building Committee models

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…