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

Method _fit_to_known

modAL/models/learners.py:114–134  ·  view source on GitHub ↗

Fits self.estimator to the training data and labels provided to it so far. Args: bootstrap: If True, the method trains the model on a set bootstrapped from the known training instances. **fit_kwargs: Keyword arguments to be passed to the fit method of the pr

(self, bootstrap: bool = False, **fit_kwargs)

Source from the content-addressed store, hash-verified

112 'agree with the training data and labels provided so far')
113
114 def _fit_to_known(self, bootstrap: bool = False, **fit_kwargs) -> 'BaseLearner':
115 """
116 Fits self.estimator to the training data and labels provided to it so far.
117
118 Args:
119 bootstrap: If True, the method trains the model on a set bootstrapped from the known training instances.
120 **fit_kwargs: Keyword arguments to be passed to the fit method of the predictor.
121
122 Returns:
123 self
124 """
125 if not bootstrap:
126 self.estimator.fit(self.X_training, self.y_training, **fit_kwargs)
127 else:
128 n_instances = self.X_training.shape[0]
129 bootstrap_idx = np.random.choice(
130 range(n_instances), n_instances, replace=True)
131 self.estimator.fit(
132 self.X_training[bootstrap_idx], self.y_training[bootstrap_idx], **fit_kwargs)
133
134 return self
135
136 def fit(self, X: modALinput, y: modALinput, bootstrap: bool = False, **fit_kwargs) -> 'BaseLearner':
137 """

Callers 4

__init__Method · 0.95
fitMethod · 0.95
teachMethod · 0.95
teachMethod · 0.45

Calls 1

fitMethod · 0.45

Tested by

no test coverage detected