|
7 | 7 | # License: MIT |
8 | 8 |
|
9 | 9 | import math |
| 10 | +import warnings |
10 | 11 | from collections import Counter |
11 | 12 |
|
12 | 13 | import numpy as np |
@@ -238,6 +239,12 @@ class SMOTE(BaseSMOTE): |
238 | 239 |
|
239 | 240 | {n_jobs} |
240 | 241 |
|
| 242 | + .. deprecated:: 0.10 |
| 243 | + `n_jobs` has been deprecated in 0.10 and will be removed in 0.12. |
| 244 | + It was previously used to set `n_jobs` of nearest neighbors |
| 245 | + algorithm. From now on, you can pass an estimator where `n_jobs` is |
| 246 | + already set instead. |
| 247 | +
|
241 | 248 | Attributes |
242 | 249 | ---------- |
243 | 250 | sampling_strategy_ : dict |
@@ -316,6 +323,15 @@ def __init__( |
316 | 323 | ) |
317 | 324 |
|
318 | 325 | def _fit_resample(self, X, y): |
| 326 | + # FIXME: to be removed in 0.12 |
| 327 | + if self.n_jobs is not None: |
| 328 | + warnings.warn( |
| 329 | + "The parameter `n_jobs` has been deprecated in 0.10 and will be " |
| 330 | + "removed in 0.12. You can pass an nearest neighbors estimator where " |
| 331 | + "`n_jobs` is already set instead.", |
| 332 | + FutureWarning, |
| 333 | + ) |
| 334 | + |
319 | 335 | self._validate_estimator() |
320 | 336 |
|
321 | 337 | X_resampled = [X.copy()] |
@@ -388,6 +404,12 @@ class SMOTENC(SMOTE): |
388 | 404 |
|
389 | 405 | {n_jobs} |
390 | 406 |
|
| 407 | + .. deprecated:: 0.10 |
| 408 | + `n_jobs` has been deprecated in 0.10 and will be removed in 0.12. |
| 409 | + It was previously used to set `n_jobs` of nearest neighbors |
| 410 | + algorithm. From now on, you can pass an estimator where `n_jobs` is |
| 411 | + already set instead. |
| 412 | +
|
391 | 413 | See Also |
392 | 414 | -------- |
393 | 415 | SMOTE : Over-sample using SMOTE. |
@@ -496,6 +518,15 @@ def _validate_estimator(self): |
496 | 518 | ) |
497 | 519 |
|
498 | 520 | def _fit_resample(self, X, y): |
| 521 | + # FIXME: to be removed in 0.12 |
| 522 | + if self.n_jobs is not None: |
| 523 | + warnings.warn( |
| 524 | + "The parameter `n_jobs` has been deprecated in 0.10 and will be " |
| 525 | + "removed in 0.12. You can pass an nearest neighbors estimator where " |
| 526 | + "`n_jobs` is already set instead.", |
| 527 | + FutureWarning, |
| 528 | + ) |
| 529 | + |
499 | 530 | self.n_features_ = X.shape[1] |
500 | 531 | self._validate_estimator() |
501 | 532 |
|
@@ -636,7 +667,7 @@ def _generate_samples(self, X, nn_data, nn_num, rows, cols, steps): |
636 | 667 | class SMOTEN(SMOTE): |
637 | 668 | """Synthetic Minority Over-sampling Technique for Nominal. |
638 | 669 |
|
639 | | - This method is refered as SMOTEN in [1]_. It expects that the data to |
| 670 | + This method is referred as SMOTEN in [1]_. It expects that the data to |
640 | 671 | resample are only made of categorical features. |
641 | 672 |
|
642 | 673 | Read more in the :ref:`User Guide <smote_adasyn>`. |
@@ -664,6 +695,12 @@ class SMOTEN(SMOTE): |
664 | 695 |
|
665 | 696 | {n_jobs} |
666 | 697 |
|
| 698 | + .. deprecated:: 0.10 |
| 699 | + `n_jobs` has been deprecated in 0.10 and will be removed in 0.12. |
| 700 | + It was previously used to set `n_jobs` of nearest neighbors |
| 701 | + algorithm. From now on, you can pass an estimator where `n_jobs` is |
| 702 | + already set instead. |
| 703 | +
|
667 | 704 | Attributes |
668 | 705 | ---------- |
669 | 706 | sampling_strategy_ : dict |
@@ -755,6 +792,15 @@ def _make_samples(self, X_class, klass, y_dtype, nn_indices, n_samples): |
755 | 792 | return X_new, y_new |
756 | 793 |
|
757 | 794 | def _fit_resample(self, X, y): |
| 795 | + # FIXME: to be removed in 0.12 |
| 796 | + if self.n_jobs is not None: |
| 797 | + warnings.warn( |
| 798 | + "The parameter `n_jobs` has been deprecated in 0.10 and will be " |
| 799 | + "removed in 0.12. You can pass an nearest neighbors estimator where " |
| 800 | + "`n_jobs` is already set instead.", |
| 801 | + FutureWarning, |
| 802 | + ) |
| 803 | + |
758 | 804 | self._validate_estimator() |
759 | 805 |
|
760 | 806 | X_resampled = [X.copy()] |
|
0 commit comments