Skip to content

Commit 30be926

Browse files
committed
Merge remote-tracking branch 'origin/master' into is/9360
2 parents 9899db2 + 3877493 commit 30be926

File tree

13 files changed

+53
-69
lines changed

13 files changed

+53
-69
lines changed

README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Below is a list of the methods currently implemented in this module.
138138
2. Extraction of majority-minority Tomek links [1]_
139139
3. Under-sampling with Cluster Centroids
140140
4. NearMiss-(1 & 2 & 3) [2]_
141-
5. Condensend Nearest Neighbour [3]_
141+
5. Condensed Nearest Neighbour [3]_
142142
6. One-Sided Selection [4]_
143143
7. Neighboorhood Cleaning Rule [5]_
144144
8. Edited Nearest Neighbours [6]_
@@ -163,7 +163,7 @@ Below is a list of the methods currently implemented in this module.
163163

164164
The different algorithms are presented in the sphinx-gallery_.
165165

166-
.. _sphinx-gallery: http://contrib.scikit-learn.org/imbalanced-learn/auto_examples
166+
.. _sphinx-gallery: http://contrib.scikit-learn.org/imbalanced-learn/stable/auto_examples/index.html
167167

168168

169169
References:

appveyor.yml

+9-26
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
build: false
2+
13
environment:
24
# There is no need to run the build for all the Python version /
35
# architectures combo as the generated nilearn wheel is the same on all
@@ -30,31 +32,12 @@ install:
3032
# Add Library/bin directory to fix issue
3133
# https://github.com/conda/conda/issues/1753
3234
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PYTHON%\\Library\\bin;%PATH%"
33-
34-
# Check that we have the expected version and architecture for Python
35-
- "python --version"
36-
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
37-
38-
# Installed prebuilt dependencies from conda
39-
- "conda install pip numpy scipy scikit-learn=0.19.0 pandas nose wheel matplotlib -y -q"
40-
41-
# Install other nilearn dependencies
42-
- "pip install coverage nose-timer pytest pytest-cov"
43-
- "python setup.py bdist_wheel"
44-
- ps: "ls dist"
45-
46-
# Install the generated wheel package to test it
47-
- "pip install --pre --no-index --find-links dist/ imbalanced-learn"
48-
49-
# Not a .NET project, we build in the install step instead
50-
build: false
35+
- conda install pip scipy numpy scikit-learn=0.19 pandas -y -q
36+
- conda install pytest pytest-cov -y -q
37+
- conda install nose -y -q # FIXME: remove this line when using sklearn > 0.19
38+
- pip install .
5139

5240
test_script:
53-
- powershell ./build_tools/appveyor/test.ps1
54-
55-
artifacts:
56-
# Archive the generated packages in the ci.appveyor.com build report.
57-
- path: dist\*
58-
59-
#on_success:
60-
# - TODO: upload the content of dist/*.whl to a public wheelhouse
41+
- mkdir for_test
42+
- cd for_test
43+
- pytest --pyargs imblearn --cov-report term-missing --cov=imblearn

build_tools/appveyor/test.ps1

-12
This file was deleted.

conftest.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This file is here so that when running from the root folder
2+
# ./sklearn is added to sys.path by pytest.
3+
# See https://docs.pytest.org/en/latest/pythonpath.html for more details.
4+
# For example, this allows to build extensions in place and run pytest
5+
# doc/modules/clustering.rst and use sklearn from the local folder
6+
# rather than the one from site-packages.
7+
8+
# Set numpy array str/repr to legacy behaviour on numpy > 1.13 to make
9+
# the doctests pass
10+
import numpy as np
11+
try:
12+
np.set_printoptions(legacy='1.13')
13+
except TypeError:
14+
pass

doc/ensemble.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ takes the same parameters than the scikit-learn
110110

111111
It also possible to turn a balanced bagging classifier into a balanced random
112112
forest using a decision tree classifier and setting the parameter
113-
``max_features='auto'`. It allows to randomly select a subset of features for
113+
``max_features='auto'``. It allows to randomly select a subset of features for
114114
each tree::
115115

116116
>>> brf = BalancedBaggingClassifier(

doc/over_sampling.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ for usage example.
6060
From random over-sampling to SMOTE and ADASYN
6161
---------------------------------------------
6262

63-
Apart from the random sampling with replacement, there is two popular methods
64-
to over-sample minority classes: (i) Synthetic Minority Oversampling Technique
65-
(SMOTE) and (ii) Adaptive Synthetic (ADASYN) sampling method. These algorithm
63+
Apart from the random sampling with replacement, there are two popular methods
64+
to over-sample minority classes: (i) the Synthetic Minority Oversampling Technique
65+
(SMOTE) and (ii) the Adaptive Synthetic (ADASYN) sampling method. These algorithms
6666
can be used in the same manner::
6767

6868
>>> from imblearn.over_sampling import SMOTE, ADASYN

imblearn/_version.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""
1+
"""
22
``imbalanced-learn`` is a set of python methods to deal with imbalanced
33
datset in machine learning and pattern recognition.
44
"""
@@ -21,4 +21,5 @@
2121
# Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer.
2222
# 'X.Y.dev0' is the canonical version of 'X.Y.dev'
2323
#
24+
2425
__version__ = '0.4.0.dev0'

imblearn/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def __getstate__(self):
119119

120120
def __setstate__(self, dict):
121121
"""Re-open the logger."""
122-
logger = logging.getLogger(__name__)
122+
logger = logging.getLogger(self.__module__)
123123
self.__dict__.update(dict)
124124
self.logger = logger
125125

@@ -133,7 +133,7 @@ class BaseSampler(SamplerMixin):
133133

134134
def __init__(self, ratio='auto'):
135135
self.ratio = ratio
136-
self.logger = logging.getLogger(__name__)
136+
self.logger = logging.getLogger(self.__module__)
137137

138138
def fit(self, X, y):
139139
"""Find the classes statistics before to perform sampling.

imblearn/ensemble/classifier.py

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
from ..pipeline import Pipeline
1717
from ..under_sampling import RandomUnderSampler
1818

19-
old_generate = _generate_bagging_indices
20-
2119

2220
class BalancedBaggingClassifier(BaggingClassifier):
2321
"""A Bagging classifier with additional balancing.

imblearn/over_sampling/adasyn.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616

1717

1818
class ADASYN(BaseOverSampler):
19-
"""Perform over-sampling using ADASYN.
20-
21-
Perform over-sampling using Adaptive Synthetic Sampling Approach for
22-
Imbalanced Learning.
19+
"""Perform over-sampling using Adaptive Synthetic (ADASYN) sampling
20+
approach for imbalanced datasets.
2321
2422
Read more in the :ref:`User Guide <smote_adasyn>`.
2523

imblearn/tests/test_common.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# Authors: Guillaume Lemaitre <[email protected]>
33
# Christos Aridas
44
# License: MIT
5-
65
from sklearn.utils.testing import _named_check
76

87
from imblearn.utils.estimator_checks import check_estimator, _yield_all_checks
@@ -34,3 +33,7 @@ def test_non_meta_estimators():
3433
continue
3534
for check in _yield_all_checks(name, Estimator):
3635
yield _named_check(check, name), name, Estimator
36+
37+
logger_name = Estimator().logger.name
38+
class_module_name = Estimator.__module__
39+
assert logger_name == class_module_name

imblearn/utils/estimator_checks.py

+10-13
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from sklearn.exceptions import NotFittedError
2525
from sklearn.utils.testing import assert_allclose
2626
from sklearn.utils.testing import set_random_state
27-
from sklearn.externals.funcsigs import signature
2827

2928
from imblearn.base import SamplerMixin
3029
from imblearn.over_sampling.base import BaseOverSampler
@@ -214,12 +213,10 @@ def check_samplers_sparse(name, Sampler):
214213
estimator=KMeans(random_state=1,
215214
algorithm='full'))]
216215
else:
217-
sampler_attr = signature(Sampler.__init__).parameters.keys()
218-
if 'random_state' in sampler_attr:
219-
samplers = [Sampler(random_state=0)]
220-
else:
221-
samplers = [Sampler()]
216+
samplers = [Sampler()]
217+
222218
for sampler in samplers:
219+
set_random_state(sampler)
223220
X_res_sparse, y_res_sparse = sampler.fit_sample(X_sparse, y)
224221
X_res, y_res = sampler.fit_sample(X, y)
225222
if not isinstance(sampler, BaseEnsembleSampler):
@@ -246,16 +243,16 @@ def check_samplers_pandas(name, Sampler):
246243
samplers = [Sampler(random_state=0, kind=kind)
247244
for kind in ('regular', 'borderline1',
248245
'borderline2', 'svm')]
246+
249247
elif isinstance(Sampler(), NearMiss):
250-
samplers = [Sampler(version=version)
251-
for version in (1, 2, 3)]
248+
samplers = [Sampler(version=version)
249+
for version in (1, 2, 3)]
250+
252251
else:
253-
sampler_attr = signature(Sampler.__init__).parameters.keys()
254-
if 'random_state' in sampler_attr:
255-
samplers = [Sampler(random_state=0)]
256-
else:
257-
samplers = [Sampler()]
252+
samplers = [Sampler()]
253+
258254
for sampler in samplers:
255+
set_random_state(sampler)
259256
X_res_pd, y_res_pd = sampler.fit_sample(X_pd, y_pd)
260257
X_res, y_res = sampler.fit_sample(X, y)
261258
assert_allclose(X_res_pd, X_res)

setup.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33

44
import codecs
55
import os
6-
import sys
76

87
from setuptools import find_packages, setup
9-
from imblearn import __version__
108

9+
# get __version__ from _version.py
10+
ver_file = os.path.join('imblearn', '_version.py')
11+
with open(ver_file) as f:
12+
exec(f.read())
1113

1214
DISTNAME = 'imbalanced-learn'
1315
DESCRIPTION = 'Toolbox for imbalanced dataset in machine learning.'

0 commit comments

Comments
 (0)