@@ -41,10 +41,14 @@ class SMOTETomek(BaseSampler):
4141 a :class:`imblearn.over_sampling.SMOTE` object with default parameters
4242 will be given.
4343
44- tomek : object, optional (default=Tomek())
45- The :class:`imblearn.under_sampling.Tomek` object to use. If not given,
46- a :class:`imblearn.under_sampling.Tomek` object with default parameters
47- will be given.
44+ tomek : object, optional (default=TomekLinks(sampling_strategy='all'))
45+ The :class:`imblearn.under_sampling.TomekLinks` object to use. If not
46+ given, a :class:`imblearn.under_sampling.TomekLinks` object with
47+ sampling strategy='all' will be given.
48+
49+ n_jobs : int, optional (default=1)
50+ The number of threads to open if possible.
51+ Will not apply to smote and tomek given by the user.
4852
4953 ratio : str, dict, or callable
5054 .. deprecated:: 0.4
@@ -94,12 +98,14 @@ def __init__(self,
9498 random_state = None ,
9599 smote = None ,
96100 tomek = None ,
101+ n_jobs = 1 ,
97102 ratio = None ):
98103 super (SMOTETomek , self ).__init__ ()
99104 self .sampling_strategy = sampling_strategy
100105 self .random_state = random_state
101106 self .smote = smote
102107 self .tomek = tomek
108+ self .n_jobs = n_jobs
103109 self .ratio = ratio
104110
105111 def _validate_estimator (self ):
@@ -116,6 +122,7 @@ def _validate_estimator(self):
116122 self .smote_ = SMOTE (
117123 sampling_strategy = self .sampling_strategy ,
118124 random_state = self .random_state ,
125+ n_jobs = self .n_jobs ,
119126 ratio = self .ratio )
120127
121128 if self .tomek is not None :
@@ -126,7 +133,9 @@ def _validate_estimator(self):
126133 'Got {} instead.' .format (type (self .tomek )))
127134 # Otherwise create a default TomekLinks
128135 else :
129- self .tomek_ = TomekLinks (sampling_strategy = 'all' )
136+ self .tomek_ = TomekLinks (
137+ sampling_strategy = 'all' ,
138+ n_jobs = self .n_jobs )
130139
131140 def _fit_resample (self , X , y ):
132141 self ._validate_estimator ()
0 commit comments