Skip to content

Commit f30d0cf

Browse files
Shihab-Shahriarglemaitre
authored andcommitted
EHN vectorize true-class probability calculation of InstanceHardnessThreshold (#566)
1 parent feb5a41 commit f30d0cf

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

imblearn/under_sampling/_prototype_selection/_instance_hardness_threshold.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,7 @@ def _fit_resample(self, X, y):
157157
self.estimator_.fit(X_train, y_train)
158158

159159
probs = self.estimator_.predict_proba(X_test)
160-
classes = self.estimator_.classes_
161-
probabilities[test_index] = [
162-
probs[l, np.where(classes == c)[0][0]]
163-
for l, c in enumerate(y_test)
164-
]
160+
probabilities[test_index] = probs[range(len(y_test)), y_test]
165161

166162
idx_under = np.empty((0, ), dtype=int)
167163

0 commit comments

Comments
 (0)