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

Method teach

modAL/models/learners.py:231–254  ·  view source on GitHub ↗

Trains the predictor with the passed data (warm_start decides if params are resetted or not). Args: X: The new samples for which the labels are supplied by the expert. y: Labels corresponding to the new instances in X. warm_start: If False, the

(self, X: modALinput, y: modALinput, warm_start: bool = True, bootstrap: bool = False, **fit_kwargs)

Source from the content-addressed store, hash-verified

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
241 with bagging.
242 **fit_kwargs: Keyword arguments to be passed to the fit method of the predictor.
243 """
244
245 if warm_start:
246 if not bootstrap:
247 self.estimator.partial_fit(X, y, **fit_kwargs)
248 else:
249 bootstrap_idx = np.random.choice(
250 range(X.shape[0]), X.shape[0], replace=True)
251 self.estimator.partial_fit(
252 X[bootstrap_idx], y[bootstrap_idx], **fit_kwargs)
253 else:
254 self._fit_on_new(X, y, bootstrap=bootstrap, **fit_kwargs)
255
256 @property
257 def num_epochs(self):

Callers 1

test_teachMethod · 0.95

Calls 1

_fit_on_newMethod · 0.45

Tested by 1

test_teachMethod · 0.76