Skip to content

Commit

Permalink
[BUG] Fix HIVE-COTE2 sporadic test failure (#3094)
Browse files Browse the repository at this point in the history
* ensure at least 2 classes for CIT

* 2
  • Loading branch information
Matthew Middlehurst committed Jul 26, 2022
1 parent 646ec96 commit 9debdf6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sktime/classification/interval_based/_drcif.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,11 @@ def _train_probas_for_estimator(self, y, idx):

indices = range(self.n_instances_)
subsample = rng.choice(self.n_instances_, size=self.n_instances_)

# subsample must have at least 2 unique classes
while len(np.unique(y[subsample])) == 1:
subsample = rng.choice(self.n_instances_, size=self.n_instances_)

oob = [n for n in indices if n not in subsample]

results = np.zeros((self.n_instances_, self.n_classes_))
Expand Down
5 changes: 5 additions & 0 deletions sktime/classification/kernel_based/_arsenal.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ def _train_probas_for_estimator(self, y, idx):

indices = range(self.n_instances_)
subsample = rng.choice(self.n_instances_, size=self.n_instances_)

# subsample must have at least 2 unique classes
while len(np.unique(y[subsample])) == 1:
subsample = rng.choice(self.n_instances_, size=self.n_instances_)

oob = [n for n in indices if n not in subsample]

results = np.zeros((self.n_instances_, self.n_classes_))
Expand Down
5 changes: 5 additions & 0 deletions sktime/classification/sklearn/_rotation_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,11 @@ def _train_probas_for_estimator(self, y, idx):

indices = range(self.n_instances_)
subsample = rng.choice(self.n_instances_, size=self.n_instances_)

# subsample must have at least 2 unique classes
while len(np.unique(y[subsample])) == 1:
subsample = rng.choice(self.n_instances_, size=self.n_instances_)

oob = [n for n in indices if n not in subsample]

results = np.zeros((self.n_instances_, self.n_classes_))
Expand Down

0 comments on commit 9debdf6

Please sign in to comment.