Fix all tests

This commit is contained in:
2021-01-25 15:19:58 -06:00
parent 3ab3bb3c1f
commit b0b013dd0a
5 changed files with 48 additions and 14 deletions

View File

@@ -90,6 +90,13 @@ class AdaptiveClassifier(Classifier):
n_samples = x_train.shape[0]
assert y_train.shape == (n_samples, 2)
# If almost all samples belong to the same class, return a fixed prediction and
# skip all the other steps.
if y_train[:, 0].mean() > 0.999 or y_train[:, 1].mean() > 0.999:
self.classifier = CountingClassifier()
self.classifier.fit(x_train, y_train)
return
best_name, best_clf, best_score = None, None, -float("inf")
for (name, specs) in self.candidates.items():
if n_samples < specs.min_samples: