Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
iter
  • Loading branch information
glemaitre committed Feb 13, 2021
commit 4e15dfbee8aedd1be19536fe30e3629e37b3f05e
37 changes: 13 additions & 24 deletions imblearn/metrics/pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,30 +90,19 @@ def fit(self, X, y):

# list of length n_features of ndarray (n_categories, n_classes)
# compute the counts
# self.proba_per_class_ = [
# np.array(
# [
# np.bincount(
# X[y == klass, feature_idx],
# minlength=len(self.categories[feature_idx]),
# )
# for klass in self.classes
# ],
# dtype=np.float64,
# ).T
# for feature_idx in range(n_features)
# ]
self.proba_per_class_ = []
for feature_idx in range(n_features):
arr = []
for klass in self.classes:
tmp = np.bincount(
X[y == klass, feature_idx],
minlength=len(self.categories[feature_idx]),
)
tmp = np.array(tmp, dtype=np.float64).T
arr.append(tmp)
self.proba_per_class_.append(arr)
self.proba_per_class_ = [
np.array(
[
np.bincount(
X[y == klass, feature_idx],
minlength=len(self.categories[feature_idx]),
)
for klass in self.classes
],
dtype=np.float64,
).T
for feature_idx in range(n_features)
]
# normalize by the summing over the classes
for feature_idx in range(n_features):
self.proba_per_class_[feature_idx] /= (
Expand Down