# [MRG+2] Neighborhood Components Analysis #10058

Merged
merged 89 commits into from Feb 28, 2019
+1,664 −23
Merged

# [MRG+2] Neighborhood Components Analysis#10058

Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
Filter file types
Failed to load files and symbols.

#### Just for now

few nitpicks and make some links in the doc work

wdevazelhes committed Feb 27, 2019
commit 3a78d1a8c557b53b00a3c745b91f0bc3b349bba3
@@ -546,7 +546,7 @@ the original space, sample 3 has many stochastic neighbors from various
classes, so the right class is not very likely. However, in the projected space
learned by NCA, the only stochastic neighbors with non-negligible weight are
from the same class as sample 3, guaranteeing that the latter will be well
classified. See the :ref:`mathematical formulation<mathematical_formulation>`
classified. See the :ref:`mathematical formulation <nca_mathematical_formulation>`
for more details.

This conversation was marked as resolved by GaelVaroquaux

@@ -647,8 +647,8 @@ Mathematical formulation

The goal of NCA is to learn an optimal linear transformation matrix of size
``(n_components, n_features)``, which maximises the sum over all samples
:math:`i` of the probability :math:`p_i` that math:`i` is correctly classified,
i.e.:
:math:`i` of the probability :math:`p_i` that :math:`i` is correctly
classified, i.e.:

.. math::
@@ -33,7 +33,7 @@ class NeighborhoodComponentsAnalysis(BaseEstimator, TransformerMixin):
to improve the classification accuracy of a stochastic nearest neighbors
rule in the transformed space.
Read more in the :ref:`User Guide <NeighborhoodComponentsAnalysis>`.
Read more in the :ref:`User Guide <nca>`.
Parameters
----------
@@ -58,14 +58,14 @@ class NeighborhoodComponentsAnalysis(BaseEstimator, TransformerMixin):
'pca'
``n_components`` principal components of the inputs passed
to :meth:`fit` will be used to initialize the transformation.

#### agramfort Nov 17, 2017

Member

all params are not indented the same way

#### wdevazelhes Nov 22, 2017

Author Contributor

This is because `pca`, `identity`, `random` and `numpy array` are not arguments but they are possible choices for argument `init`. I took the syntax from LMNN. Should I write it in another way ?

(See :class:`PCA`)
(See `decomposition.PCA`)
'lda'
``min(n_components, n_classes)`` most discriminative
components of the inputs passed to :meth:`fit` will be used to
initialize the transformation. (If ``n_components > n_classes``,
the rest of the components will be zero.) (See
:class:`LinearDiscriminantAnalysis`)
`discriminant_analysis.LinearDiscriminantAnalysis`)
'identity'
If ``n_components`` is strictly smaller than the
@@ -74,7 +74,7 @@ class NeighborhoodComponentsAnalysis(BaseEstimator, TransformerMixin):
'random'
The initial transformation will be a random array of shape
(n_components, n_features). Each value is sampled from the
`(n_components, n_features)`. Each value is sampled from the
standard normal distribution.
numpy array
@@ -102,9 +102,9 @@ class NeighborhoodComponentsAnalysis(BaseEstimator, TransformerMixin):
verbose : int, optional (default=0)
If 0, no progress messages will be printed.
If 1, progress messages will be printed to stdout.
If > 1, progress messages will be printed and the ``iprint``
parameter of :meth:`_minimize_lbfgsb` of `scipy.optimize` will be set
to ``verbose - 2``.
If > 1, progress messages will be printed and the ``disp``
parameter of :func:`scipy.optimize.minimize` will be set to
``verbose - 2``.
random_state : int or numpy.RandomState or None, optional (default=None)
A pseudo random number generator object or a seed for it if int. If
 @@ -821,7 +821,7 @@ def test_check_scalar_valid(x, target_type, min_val, max_val): ValueError('`test_name3`= 5, must be <= 4.'))]) def test_check_scalar_invalid(x, target_name, target_type, min_val, max_val, err_msg): """Test that check_scalar returns the right error if a wrong input type is """Test that check_scalar returns the right error if a wrong input is given""" with pytest.raises(Exception) as raised_error: check_scalar(x, target_name, target_type=target_type,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.