Skip to content
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

[MRG+2] Fix trustworthiness custom metric #9775

Merged

Fix the position of the deprecation in docstring.

  • Loading branch information...
wdevazelhes committed Sep 14, 2017
commit 87036af8ebaa83e451fad9e04c2ed0853b386693
Copy path View file
@@ -379,7 +379,7 @@ def _gradient_descent(objective, p0, it, n_iter,


def trustworthiness(X, X_embedded, n_neighbors=5,
precomputed=None, metric='euclidean'):
precomputed=False, metric='euclidean'):
"""Expresses to what extent the local structure is retained.
The trustworthiness is within [0, 1]. It is defined as
@@ -400,10 +400,6 @@ def trustworthiness(X, X_embedded, n_neighbors=5,
* "Learning a Parametric Embedding by Preserving Local Structure"
L.J.P. van der Maaten
..deprecated:: 0.20
The boolean flag ``precomputed`` is deprecated in version 0.20 and will
be removed in version 0.22. Use parameter ``metric`` instead.
Parameters
----------
X : array, shape (n_samples, n_features) or (n_samples, n_samples)
@@ -416,6 +412,13 @@ def trustworthiness(X, X_embedded, n_neighbors=5,
n_neighbors : int, optional (default: 5)
Number of neighbors k that will be considered.
precomputed : bool, optional (default: False)
Set this flag if X is a precomputed square distance matrix.
..deprecated:: 0.20
``precomputed`` has been deprecated in version 0.20 and will be
removed in version 0.22. Use ``metric`` instead.
metric : string, or callable, optional, default 'euclidean'
Which metric to use for computing pairwise distances between samples
from the original input space. If metric is 'precomputed', X must be a
@@ -429,11 +432,11 @@ def trustworthiness(X, X_embedded, n_neighbors=5,
trustworthiness : float
Trustworthiness of the low-dimensional embedding.
"""
if precomputed is not None:
warnings.warn("The flag 'precomputed' is deprecated in version 0.20 "
"and will be removed in 0.22. See 'metric' parameter "
"instead.", DeprecationWarning)
metric = 'precomputed' if precomputed else metric
if precomputed:
warnings.warn("The flag 'precomputed' has been deprecated in version"

This comment has been minimized.

Copy link
@massich

massich Sep 15, 2017

Contributor

Check scikit-learn contributing guide to see howto deprecate the precomputed attribute using a decorator.

This comment has been minimized.

Copy link
@massich

massich Sep 15, 2017

Contributor

and precomputed is not an attribute but a parameter. (my bad. sorry)

"0.20 and will be removed in 0.22. See 'metric'"
"parameter instead.", DeprecationWarning)
metric = 'precomputed'
if metric == 'precomputed':

This comment has been minimized.

Copy link
@jnothman

jnothman Sep 19, 2017

Member

I think pairwise_distances handled precomputed, so we don't need a special case here

This comment has been minimized.

Copy link
@wdevazelhes

wdevazelhes Sep 20, 2017

Author Contributor

Thanks, I will change this

dist_X = X
elif metric == 'euclidean':
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.