Skip to content

Commit 8158ddd

Browse files
glemaitrechkoar
authored andcommitted
MAINT: Set n_jobs default to 1 (#187)
1 parent 4889c2e commit 8158ddd

18 files changed

+30
-30
lines changed

imblearn/combine/smote_enn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def _validate_estimator(self):
175175
if self.kind_smote is None:
176176
self.kind_smote = 'regular'
177177
if self.n_jobs is None:
178-
smote_jobs = -1
178+
smote_jobs = 1
179179
else:
180180
smote_jobs = self.n_jobs
181181
warnings.warn('Parameters initialization will be replaced in'
@@ -210,7 +210,7 @@ def _validate_estimator(self):
210210
if self.kind_enn is None:
211211
self.kind_enn = 'all'
212212
if self.n_jobs is None:
213-
self.n_jobs = -1
213+
self.n_jobs = 1
214214
self.enn_ = EditedNearestNeighbours(random_state=self.random_state,
215215
size_ngh=self.size_ngh,
216216
n_neighbors=self.n_neighbors,

imblearn/combine/smote_tomek.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def _validate_estimator(self):
151151
if self.kind_smote is None:
152152
self.kind_smote = 'regular'
153153
if self.n_jobs is None:
154-
smote_jobs = -1
154+
smote_jobs = 1
155155
else:
156156
smote_jobs = self.n_jobs
157157
self.smote_ = SMOTE(ratio=self.ratio,

imblearn/over_sampling/smote.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ class SMOTE(BaseBinarySampler):
6868
The type of SMOTE algorithm to use one of the following options:
6969
'regular', 'borderline1', 'borderline2', 'svm'.
7070
71+
n_jobs : int, optional (default=1)
72+
The number of threads to open if possible.
73+
7174
Attributes
7275
----------
7376
min_c_ : str or int
@@ -125,7 +128,7 @@ class SMOTE(BaseBinarySampler):
125128

126129
def __init__(self, ratio='auto', random_state=None, k=None, k_neighbors=5,
127130
m=None, m_neighbors=10, out_step=0.5, kind='regular',
128-
n_jobs=-1, **kwargs):
131+
n_jobs=1, **kwargs):
129132
super(SMOTE, self).__init__(ratio=ratio, random_state=random_state)
130133
self.kind = kind
131134
self.k = k

imblearn/pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ class Pipeline(pipeline.Pipeline):
100100
>>> pipeline = Pipeline([('smt', smt), ('pca', pca), ('knn', knn)])
101101
>>> X_train, X_test, y_train, y_test = tts(X, y, random_state=42)
102102
>>> pipeline.fit(X_train, y_train)
103-
Pipeline(steps=[('smt', SMOTE(k=None, k_neighbors=5, kind='regular', m=None, m_neighbors=10,
104-
n_jobs=-1, out_step=0.5, random_state=42, ratio='auto')), ('pca', PCA(copy=True, n_components=None, whiten=False)), ('knn', KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',
103+
Pipeline(steps=[('smt', SMOTE(k=None, k_neighbors=5, kind='regular', m=None, m_neighbors=10, n_jobs=1,
104+
out_step=0.5, random_state=42, ratio='auto')), ('pca', PCA(copy=True, n_components=None, whiten=False)), ('knn', KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',
105105
metric_params=None, n_jobs=1, n_neighbors=5, p=2,
106106
weights='uniform'))])
107107
>>> y_hat = pipeline.predict(X_test)

imblearn/under_sampling/cluster_centroids.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ClusterCentroids(BaseMulticlassSampler):
3535
If None, the random number generator is the RandomState instance used
3636
by np.random.
3737
38-
n_jobs : int, optional (default=-1)
38+
n_jobs : int, optional (default=1)
3939
The number of threads to open if possible.
4040
4141
**kwargs : keywords
@@ -79,7 +79,7 @@ class ClusterCentroids(BaseMulticlassSampler):
7979
8080
"""
8181

82-
def __init__(self, ratio='auto', random_state=None, n_jobs=-1, **kwargs):
82+
def __init__(self, ratio='auto', random_state=None, n_jobs=1, **kwargs):
8383
super(ClusterCentroids, self).__init__(ratio=ratio,
8484
random_state=random_state)
8585
self.n_jobs = n_jobs

imblearn/under_sampling/condensed_nearest_neighbour.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class CondensedNearestNeighbour(BaseMulticlassSampler):
4343
n_seeds_S : int, optional (default=1)
4444
Number of samples to extract in order to build the set S.
4545
46-
n_jobs : int, optional (default=-1)
46+
n_jobs : int, optional (default=1)
4747
The number of threads to open if possible.
4848
4949
**kwargs : keywords
@@ -95,7 +95,7 @@ class CondensedNearestNeighbour(BaseMulticlassSampler):
9595
"""
9696

9797
def __init__(self, return_indices=False, random_state=None,
98-
size_ngh=None, n_neighbors=1, n_seeds_S=1, n_jobs=-1,
98+
size_ngh=None, n_neighbors=1, n_seeds_S=1, n_jobs=1,
9999
**kwargs):
100100
super(CondensedNearestNeighbour, self).__init__(
101101
random_state=random_state)

imblearn/under_sampling/edited_nearest_neighbours.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class EditedNearestNeighbours(BaseMulticlassSampler):
5353
- If 'mode', the majority vote of the neighbours will be used in
5454
order to exclude a sample.
5555
56-
n_jobs : int, optional (default=-1)
56+
n_jobs : int, optional (default=1)
5757
The number of threads to open if possible.
5858
5959
Attributes
@@ -103,7 +103,7 @@ class EditedNearestNeighbours(BaseMulticlassSampler):
103103
"""
104104

105105
def __init__(self, return_indices=False, random_state=None,
106-
size_ngh=None, n_neighbors=3, kind_sel='all', n_jobs=-1):
106+
size_ngh=None, n_neighbors=3, kind_sel='all', n_jobs=1):
107107
super(EditedNearestNeighbours, self).__init__(
108108
random_state=random_state)
109109
self.return_indices = return_indices

imblearn/under_sampling/instance_hardness_threshold.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class InstanceHardnessThreshold(BaseBinarySampler):
4444
cv : int, optional (default=5)
4545
Number of folds to be used when estimating samples' instance hardness.
4646
47-
n_jobs : int, optional (default=-1)
47+
n_jobs : int, optional (default=1)
4848
The number of threads to open if possible.
4949
5050
Attributes
@@ -97,7 +97,7 @@ class InstanceHardnessThreshold(BaseBinarySampler):
9797
"""
9898

9999
def __init__(self, estimator='linear-svm', ratio='auto',
100-
return_indices=False, random_state=None, cv=5, n_jobs=-1,
100+
return_indices=False, random_state=None, cv=5, n_jobs=1,
101101
**kwargs):
102102
super(InstanceHardnessThreshold, self).__init__(
103103
ratio=ratio,

imblearn/under_sampling/nearmiss.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class NearMiss(BaseMulticlassSampler):
6666
`sklearn.neighbors.base.KNeighborsMixin` that will be used to find
6767
the k_neighbors.
6868
69-
n_jobs : int, optional (default=-1)
69+
n_jobs : int, optional (default=1)
7070
The number of threads to open if possible.
7171
7272
Attributes
@@ -117,7 +117,7 @@ class NearMiss(BaseMulticlassSampler):
117117

118118
def __init__(self, ratio='auto', return_indices=False, random_state=None,
119119
version=1, size_ngh=None, n_neighbors=3, ver3_samp_ngh=None,
120-
n_neighbors_ver3=3, n_jobs=-1):
120+
n_neighbors_ver3=3, n_jobs=1):
121121
super(NearMiss, self).__init__(ratio=ratio, random_state=random_state)
122122
self.return_indices = return_indices
123123
self.version = version

imblearn/under_sampling/neighbourhood_cleaning_rule.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class NeighbourhoodCleaningRule(BaseMulticlassSampler):
4040
`sklearn.neighbors.base.KNeighborsMixin` that will be used to find
4141
the k_neighbors.
4242
43-
n_jobs : int, optional (default=-1)
43+
n_jobs : int, optional (default=1)
4444
The number of threads to open if possible.
4545
4646
Attributes
@@ -87,7 +87,7 @@ class NeighbourhoodCleaningRule(BaseMulticlassSampler):
8787
"""
8888

8989
def __init__(self, return_indices=False, random_state=None,
90-
size_ngh=None, n_neighbors=3, n_jobs=-1):
90+
size_ngh=None, n_neighbors=3, n_jobs=1):
9191
super(NeighbourhoodCleaningRule, self).__init__(
9292
random_state=random_state)
9393
self.return_indices = return_indices

0 commit comments

Comments
 (0)