Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[MRG+1] Deprecating the use of size_threshold parameter in manhattan_distances #9295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion sklearn/metrics/pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import itertools
from functools import partial
import warnings

import numpy as np
from scipy.spatial import distance
Expand Down Expand Up @@ -467,7 +468,7 @@ def pairwise_distances_argmin(X, Y, axis=1, metric="euclidean",


def manhattan_distances(X, Y=None, sum_over_features=True,
size_threshold=5e8):
size_threshold=None):
""" Compute the L1 distances between the vectors in X and Y.

With sum_over_features equal to False it returns the componentwise
Expand Down Expand Up @@ -520,6 +521,10 @@ def manhattan_distances(X, Y=None, sum_over_features=True,
array([[ 1., 1.],
[ 1., 1.]]...)
"""
if size_threshold is not None:
warnings.warn('Use of the "size_threshold" is deprecated '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please explicitly mention the version in which it is deprecated (0.19) and the one in which it will be removed (0.21)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will do it.

'in 0.19 and it will be removed version '
'0.21 of scikit-learn', DeprecationWarning)
X, Y = check_pairwise_arrays(X, Y)

if issparse(X) or issparse(Y):
Expand Down
9 changes: 5 additions & 4 deletions sklearn/metrics/tests/test_pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from sklearn.utils.testing import assert_raises
from sklearn.utils.testing import assert_raises_regexp
from sklearn.utils.testing import assert_true
from sklearn.utils.testing import assert_warns
from sklearn.utils.testing import ignore_warnings

from sklearn.externals.six import iteritems
Expand Down Expand Up @@ -74,10 +75,10 @@ def test_pairwise_distances():
assert_equal(S.shape[0], X.shape[0])
assert_equal(S.shape[1], Y.shape[0])
assert_array_almost_equal(S, S2)
# Low-level function for manhattan can divide in blocks to avoid
# using too much memory during the broadcasting
S3 = manhattan_distances(X, Y, size_threshold=10)
assert_array_almost_equal(S, S3)
# Using size_threshold argument should raise
# a deprecation warning
assert_warns(DeprecationWarning,
manhattan_distances, X, Y, size_threshold=10)
# Test cosine as a string metric versus cosine callable
# The string "cosine" uses sklearn.metric,
# while the function cosine is scipy.spatial
Expand Down