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

Method teach

modAL/models/learners.py:160–180  ·  view source on GitHub ↗

Adds X and y to the known training data and retrains the predictor with the augmented dataset. Args: X: The new samples for which the labels are supplied by the expert. y: Labels corresponding to the new instances in X. bootstrap: If True, traini

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

Source from the content-addressed store, hash-verified

158 return self._fit_to_known(bootstrap=bootstrap, **fit_kwargs)
159
160 def teach(self, X: modALinput, y: modALinput, bootstrap: bool = False, only_new: bool = False, **fit_kwargs) -> None:
161 """
162 Adds X and y to the known training data and retrains the predictor with the augmented dataset.
163
164 Args:
165 X: The new samples for which the labels are supplied by the expert.
166 y: Labels corresponding to the new instances in X.
167 bootstrap: If True, training is done on a bootstrapped dataset. Useful for building Committee models
168 with bagging.
169 only_new: If True, the model is retrained using only X and y, ignoring the previously provided examples.
170 Useful when working with models where the .fit() method doesn't retrain the model from scratch (e. g. in
171 tensorflow or keras).
172 **fit_kwargs: Keyword arguments to be passed to the fit method of the predictor.
173 """
174 if not only_new:
175 self._add_training_data(X, y)
176 self._fit_to_known(bootstrap=bootstrap, **fit_kwargs)
177 else:
178 check_X_y(X, y, accept_sparse=True, ensure_2d=False, allow_nd=True, multi_output=True, dtype=None,
179 force_all_finite=self.force_all_finite)
180 self._fit_on_new(X, y, bootstrap=bootstrap, **fit_kwargs)
181
182
183class DeepActiveLearner(BaseLearner):

Callers 8

test_teachMethod · 0.95
test_nanMethod · 0.95
test_sparse_matricesMethod · 0.95
test_on_transformedMethod · 0.95
modAL_uncertaintyFunction · 0.95
modAL_EERFunction · 0.95

Calls 3

_add_training_dataMethod · 0.95
_fit_to_knownMethod · 0.95
_fit_on_newMethod · 0.45

Tested by 6

test_teachMethod · 0.76
test_nanMethod · 0.76
test_sparse_matricesMethod · 0.76
test_on_transformedMethod · 0.76