Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc resample bench #24

Merged
merged 23 commits into from
Dec 8, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

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
updated num_core
  • Loading branch information
plutasnyy committed Dec 4, 2019
commit 84da4b147ed1380b0b655ba47b1ce85c668d13ff
10 changes: 5 additions & 5 deletions multi_imbalance/ensemble/SOUPBagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ def fit_clf(args):


class SOUPBagging(object):
def __init__(self, classifier=None, n_classifiers=30):
def __init__(self, classifier=None, n_classifiers=5):
self.classifiers = list()
self.num_core = multiprocessing.cpu_count()
self.n_classifiers = n_classifiers
self.classes = None
for _ in range(n_classifiers):
Expand All @@ -39,9 +40,7 @@ def fit(self, X, y):
"""
self.classes = np.unique(y)

NUM_CORE = multiprocessing.cpu_count()

pool = multiprocessing.Pool(NUM_CORE)
pool = multiprocessing.Pool(self.num_core)
self.classifiers = pool.map(fit_clf, [(clf, X, y) for clf in self.classifiers])
pool.close()
pool.join()
Expand Down Expand Up @@ -73,4 +72,5 @@ def predict_proba(self, X):
for i, clf in enumerate(self.classifiers):
results[i] = clf.predict_proba(X)

return results
p = np.sum(results, axis=0)
return p