8000 MNT Release 0.19.2 with python 3.7 support (#11422) · scikit-learn/scikit-learn@7c3944f · GitHub
[go: up one dir, main page]

Skip to content

Commit 7c3944f

Browse files
jnothmanogrisel
authored andcommitted
MNT Release 0.19.2 with python 3.7 support (#11422)
1 parent a24c8b4 commit 7c3944f

File tree

16 files changed

+101
-41
lines changed

16 files changed

+101
-41
lines changed

.travis.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,17 @@ matrix:
3535
- env: DISTRIB="conda" PYTHON_VERSION="2.7" INSTALL_MKL="false"
3636
NUMPY_VERSION="1.8.2" SCIPY_VERSION="0.13.3" CYTHON_VERSION="0.23.5"
3737
COVERAGE=true
38-
# This environment tests the newest supported Anaconda release (4.4.0)
38+
# This environment tests the a recent Anaconda release (4.4.0)
3939
# It also runs tests requiring Pandas.
4040
- env: DISTRIB="conda" PYTHON_VERSION="3.6.1" INSTALL_MKL="true"
4141
NUMPY_VERSION="1.12.1" SCIPY_VERSION="0.19.0" PANDAS_VERSION="0.20.1"
4242
CYTHON_VERSION="0.25.2" COVERAGE=true
4343
# This environment use pytest to run the tests. It uses the newest
44-
# supported Anaconda release (4.4.0). It also runs tests requiring Pandas.
45-
- env: USE_PYTEST="true" DISTRIB="conda" PYTHON_VERSION="3.6.1"
46-
INSTALL_MKL="true" NUMPY_VERSION="1.12.1" SCIPY_VERSION="0.19.0"
47-
PANDAS_VERSION="0.20.1" CYTHON_VERSION="0.25.2"
44+
# supported Anaconda release.
45+
- env: USE_PYTEST="true" DISTRIB="conda" PYTHON_VERSION="3.7.0"
46+
INSTALL_MKL="true" NUMPY_VERSION="1.14.5" SCIPY_VERSION="1.1.0"
47+
CYTHON_VERSION="0.27.3"
48+
# PANDAS_VERSION="0.20.1"
4849
# flake8 linting on diff wrt common ancestor with upstream/master
4950
- env: RUN_FLAKE8="true" SKIP_TESTS="true"
5051
DISTRIB="conda" PYTHON_VERSION="3.5" INSTALL_MKL="true"

appveyor.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ environment:
2525
PYTHON_VERSION: "2.7.8"
2626
PYTHON_ARCH: "64"
2727

28-
- PYTHON: "C:\\Python35"
29-
PYTHON_VERSION: "3.5.0"
28+
- PYTHON: "C:\\Python37"
29+
PYTHON_VERSION: "3.7.0"
3030
PYTHON_ARCH: "32"
3131

32-
- PYTHON: "C:\\Python35-x64"
33-
PYTHON_VERSION: "3.5.0"
32+
- A93C PYTHON: "C:\\Python37-x64"
33+
PYTHON_VERSION: "3.7.0"
3434
PYTHON_ARCH: "64"
3535

3636

build_tools/appveyor/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
# fix the versions of numpy to force the use of numpy and scipy to use the whl
88
# of the rackspace folder instead of trying to install from more recent
99
# source tarball published on PyPI
10-
numpy==1.9.3
11-
scipy==0.16.0
12-
cython
10+
numpy==1.14.5
11+
scipy==1.1.0
12+
cython==0.27.3
1313
nose
1414
nose-timer
1515
wheel

build_tools/circle/build_doc.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,6 @@ source activate testenv
114114
# Build and install scikit-learn in dev mode
115115
python setup.py develop
116116

117-
if [[ "$CIRCLE_BRANCH" =~ ^master$ && -z "$CI_PULL_REQUEST" ]]
118-
then
119-
# List available documentation versions if on master
120-
python build_tools/circle/list_versions.py > doc/versions.rst
121-
fi
122-
123117
# The pipefail is requested to propagate exit code
124118
set -o pipefail && cd doc && make $MAKE_TARGET 2>&1 | tee ~/log.txt
125119

build_tools/travis/install.sh

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,23 @@ if [[ "$DISTRIB" == "conda" ]]; then
4141
# Configure the conda environment and put it in the path using the
4242
# provided versions
4343
if [[ "$INSTALL_MKL" == "true" ]]; then
44-
conda create -n testenv --yes python=$PYTHON_VERSION pip nose pytest \
45-
numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION \
46-
mkl cython=$CYTHON_VERSION \
47-
${PANDAS_VERSION+pandas=$PANDAS_VERSION}
44+
conda create -n testenv --yes python=$PYTHON_VERSION pip \
45+
numpy=$NUMPY_VERSION \
46+
mkl
4847

4948
else
50-
conda create -n testenv --yes python=$PYTHON_VERSION pip nose pytest \
51-
numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION \
52-
nomkl cython=$CYTHON_VERSION \
53-
${PANDAS_VERSION+pandas=$PANDAS_VERSION}
49+
conda create -n testenv --yes python=$PYTHON_VERSION pip \
50+
numpy=$NUMPY_VERSION \
51+
nomkl
5452
fi
5553
source activate testenv
5654

55+
# conda does not yet have those dependencies ready with Python 3.7.
56+
pip install nose pytest \
57+
cython==$CYTHON_VERSION \
58+
${PANDAS_VERSION+pandas==$PANDAS_VERSION} \
59+
scipy==$SCIPY_VERSION
60+
10000 5761
# Install nose-timer via pip
5862
pip install nose-timer
5963

@@ -66,7 +70,7 @@ elif [[ "$DISTRIB" == "ubuntu" ]]; then
6670
# and scipy
6771
virtualenv --system-site-packages testvenv
6872
source testvenv/bin/activate
69-
pip install nose nose-timer cython
73+
pip install nose nose-timer cython==$CYTHON_VERSION
7074

7175
elif [[ "$DISTRIB" == "scipy-dev-wheels" ]]; then
7276
# Set up our own virtualenv environment to avoid travis' numpy.

conftest.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from distutils.version import LooseVersion
2+
3+
import pytest
4+
from _pytest.doctest import DoctestItem
5+
6+
7+
def pytest_collection_modifyitems(config, items):
8+
# numpy changed the str/repr formatting of numpy arrays in 1.14. We want to
9+
# run doctests only for numpy >= 1.14.
10+
skip_doctests = True
11+
try:
12+
import numpy as np
13+
if LooseVersion(np.__version__) < LooseVersion('1.14'):
14+
skip_doctests = False
15+
except ImportError:
16+
pass
17+
18+
if skip_doctests:
19+
skip_marker = pytest.mark.skip(
20+
reason='doctests are only run for numpy < 1.14')
21+
22+
for item in items:
23+
if isinstance(item, DoctestItem):
24+
item.add_marker(skip_marker)

doc/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@
207207
<li><em>On-going development:</em>
208208
<a href="/dev/whats_new.html"><em>What's new</em> (Changelog)</a>
209209
</li>
210+
<li><em>July 2018.</em> scikit-learn 0.19.2 is available for download (<a href="whats_new.html#version-0-19-2">Changelog</a>).
211+
</li>
210212
<li><em>October 2017.</em> scikit-learn 0.19.1 is available for download (<a href="whats_new.html#version-0-19-1">Changelog</a>).
211213
</li>
212214
<li><em>July 2017.</em> scikit-learn 0.19.0 is available for download (<a href="whats_new.html#version-0-19">Changelog</a>).

doc/whats_new.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@
44
Release history
55
===============
66

7+
Version 0.19.2
8+
==============
9+
10+
**October, 2018**
11+
12+
This release is exclusively in order to support Python 3.7.
13+
14+
Related changes
15+
---------------
16+
17+
- ``n_iter_`` may vary from previous releases in
18+
:class:`linear_model.LogisticRegression` with ``solver='lbfgs'`` and
19+
:class:`linear_model.HuberRegressor`. For Scipy <= 1.0.0, the optimizer could
20+
perform more than the requested maximum number of iterations. Now both
21+
estimators will report at most ``max_iter`` iterations even if more were
22+
performed. :issue:`10723` by `Joel Nothman`_.
23+
24+
725
Version 0.19.1
826
==============
927

sklearn/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def config_context(**new_config):
114114
# Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer.
115115
# 'X.Y.dev0' is the canonical version of 'X.Y.dev'
116116
#
117-
__version__ = '0.19.1'
117+
__version__ = '0.19.2'
118118

119119

120120
try:

sklearn/exceptions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class NotFittedError(ValueError, AttributeError):
3030
... except NotFittedError as e:
3131
... print(repr(e))
3232
... # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
33-
NotFittedError('This LinearSVC instance is not fitted yet',)
33+
NotFittedError('This LinearSVC instance is not fitted yet'...)
3434
3535
.. versionchanged:: 0.18
3636
Moved from sklearn.utils.validation.
@@ -118,10 +118,10 @@ class FitFailedWarning(RuntimeWarning):
118118
... except ValueError:
119119
... pass
120120
... print(repr(w[-1].message))
121-
... # doctest: +NORMALIZE_WHITESPACE
121+
... # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
122122
FitFailedWarning("Classifier fit failed. The score on this train-test
123123
partition for these parameters will be set to 0.000000. Details:
124-
\\nValueError('Penalty term must be positive; got (C=-2)',)",)
124+
\\nValueError('Penalty term must be positive; got (C=-2)'...)
125125
126126
.. versionchanged:: 0.18
127127
Moved from sklearn.cross_validation.

sklearn/linear_model/huber.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,11 @@ class HuberRegressor(LinearModel, RegressorMixin, BaseEstimator):
181181
182182
n_iter_ : int
183183
Number of iterations that fmin_l_bfgs_b has run for.
184-
Not available if SciPy version is 0.9 and below.
184+
185+
.. versionchanged:: 0.20
186+
187+
In SciPy <= 1.0.0 the number of lbfgs iterations may exceed
188+
``max_iter``. ``n_iter_`` will now report at most ``max_iter``.
185189
186190
outliers_ : array, shape (n_samples,)
187191
A boolean mask which is set to True where the samples are identified
@@ -272,7 +276,9 @@ def fit(self, X, y, sample_weight=None):
272276
raise ValueError("HuberRegressor convergence failed:"
273277
" l-BFGS-b solver terminated with %s"
274278
% dict_['task'].decode('ascii'))
275-
self.n_iter_ = dict_.get('nit', None)
279+
# In scipy <= 1.0.0, nit may exceed maxiter.
280+
# See https://github.com/scipy/scipy/issues/7854.
281+
self.n_iter_ = min(dict_['nit'], self.max_iter)
276282
self.scale_ = parameters[-1]
277283
if self.fit_intercept:
278284
self.intercept_ = parameters[-2]

sklearn/linear_model/logistic.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from ..utils.fixes import logsumexp
3030
from ..utils.optimize import newton_cg
3131
from ..utils.validation import check_X_y
32-
from ..exceptions import NotFittedError
32+
from ..exceptions import NotFittedError, ConvergenceWarning
3333
from ..utils.multiclass import check_classification_targets
3434
from ..externals.joblib import Parallel, delayed
3535
from ..model_selection import check_cv
@@ -716,11 +716,10 @@ def logistic_regression_path(X, y, pos_class=None, Cs=10, fit_intercept=True,
716716
iprint=(verbose > 0) - 1, pgtol=tol)
717717
if info["warnflag"] == 1 and verbose > 0:
718718
warnings.warn("lbfgs failed to converge. Increase the number "
719-
"of iterations.")
720-
try:
721-
n_iter_i = info['nit'] - 1
722-
except:
723-
n_iter_i = info['funcalls'] - 1
719+
"of iterations.", ConvergenceWarning)
720+
# In scipy <= 1.0.0, nit may exceed maxiter.
721+
# See https://github.com/scipy/scipy/issues/7854.
722+
n_iter_i = min(info['nit'], max_iter)
724723
elif solver == 'newton-cg':
725724
args = (X, target, 1. / C, sample_weight)
726725
w0, n_iter_i = newton_cg(hess, func, grad, w0, args=args,
@@ -1115,6 +1114,11 @@ class LogisticRegression(BaseEstimator, LinearClassifierMixin,
11151114
it returns only 1 element. For liblinear solver, only the maximum
11161115
number of iteration across all classes is given.
11171116
1117+
.. versionchanged:: 0.20
1118+
1119+
In SciPy <= 1.0.0 the number of lbfgs iterations may exceed
1120+
``max_iter``. ``n_iter_`` will now report at most ``max_iter``.
1121+
11181122
See also
11191123
--------
11201124
SGDClassifier : incrementally trained logistic regression (when given

sklearn/linear_model/tests/test_huber.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ def test_huber_equals_lr_for_high_epsilon():
4242
assert_almost_equal(huber.intercept_, lr.intercept_, 2)
4343

4444

45+
def test_huber_max_iter():
46+
X, y = make_regression_with_outliers()
47+
huber = HuberRegressor(max_iter=1)
48+
huber.fit(X, y)
49+
assert huber.n_iter_ == huber.max_iter
50+
51+
4552
def test_huber_gradient():
4653
# Test that the gradient calculated by _huber_loss_and_gradient is correct
4754
rng = np.random.RandomState(1)

sklearn/metrics/cluster/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
def configuration(parent_package="", top_path=None):
8-
config = Configuration("metrics/cluster", parent_package, top_path)
8+
config = Configuration("cluster", parent_package, top_path)
99
libraries = []
1010
if os.name == 'posix':
1111
libraries.append('m')

sklearn/metrics/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def configuration(parent_package="", top_path=None):
1414
if os.name == 'posix':
1515
cblas_libs.append('m')
1616

17+
config.add_subpackage('cluster')
1718
config.add_extension("pairwise_fast",
1819
sources=["pairwise_fast.pyx"],
1920
include_dirs=[os.path.join('..', 'src', 'cblas'),

sklearn/setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def configuration(parent_package='', top_path=None):
5151
config.add_subpackage('feature_extraction')
5252
config.add_subpackage('manifold')
5353
config.add_subpackage('metrics')
54-
config.add_subpackage('metrics/cluster')
5554
config.add_subpackage('neighbors')
5655
config.add_subpackage('tree')
5756
config.add_subpackage('svm')

0 commit comments

Comments
 (0)
0