Fit a single binary estimator.
(estimator, X, y, fit_params, classes=None)
| 79 | |
| 80 | |
| 81 | def _fit_binary(estimator, X, y, fit_params, classes=None): |
| 82 | """Fit a single binary estimator.""" |
| 83 | unique_y = np.unique(y) |
| 84 | if len(unique_y) == 1: |
| 85 | if classes is not None: |
| 86 | if y[0] == -1: |
| 87 | c = 0 |
| 88 | else: |
| 89 | c = y[0] |
| 90 | warnings.warn( |
| 91 | "Label %s is present in all training examples." % str(classes[c]) |
| 92 | ) |
| 93 | estimator = _ConstantPredictor().fit(X, unique_y) |
| 94 | else: |
| 95 | estimator = clone(estimator) |
| 96 | estimator.fit(X, y, **fit_params) |
| 97 | return estimator |
| 98 | |
| 99 | |
| 100 | def _partial_fit_binary(estimator, X, y, partial_fit_params): |
no test coverage detected
searching dependent graphs…