Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

correctly updates known classes after teaching estimators #63

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions modAL/models/learners.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,20 @@ def _set_classes(self):

def _add_training_data(self, X: modALinput, y: modALinput):
super()._add_training_data(X, y)

def teach(self, X: modALinput, y: modALinput, bootstrap: bool = False, only_new: bool = False, **fit_kwargs) -> None:
"""
Adds X and y to the known training data for each learner and retrains learners 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, trains each learner on a bootstrapped set. Useful when building the ensemble by bagging.
only_new: If True, the model is retrained using only X and y, ignoring the previously provided examples.
**fit_kwargs: Keyword arguments to be passed to the fit method of the predictor.
"""

super().teach(X, y, bootstrap=bootstrap, only_new=only_new, **fit_kwargs)
self._set_classes()

def predict(self, X: modALinput, **predict_proba_kwargs) -> Any:
Expand Down