Skip to content

Commit 319bc5d

Browse files
authored
Merge branch 'scikit-learn-contrib:master' into master
2 parents d0a7a24 + 5427159 commit 319bc5d

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

doc/supervised.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,11 @@ same class are not imposed to be close.
292292
lfda = LFDA(k=2, dim=2)
293293
lfda.fit(X, Y)
294294

295+
.. note::
296+
LDFA suffers from a problem called “sign indeterminacy”, which means the sign of the ``components`` and the output from transform depend on a random state. This is directly related to the calculation of eigenvectors in the algorithm. The same input ran in different times might lead to different transforms, but both valid.
297+
298+
To work around this, fit instances of this class to data once, then keep the instance around to do transformations.
299+
295300
.. topic:: References:
296301

297302
.. [1] Sugiyama. `Dimensionality Reduction of Multimodal Labeled Data by Local

test/metric_learn_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ def test_singleton_class(self):
929929
X = X[[ind_0[0], ind_1[0], ind_2[0]]]
930930
y = y[[ind_0[0], ind_1[0], ind_2[0]]]
931931

932-
A = make_spd_matrix(X.shape[1], X.shape[1])
932+
A = make_spd_matrix(n_dim=X.shape[1], random_state=X.shape[1])
933933
nca = NCA(init=A, max_iter=30, n_components=X.shape[1])
934934
nca.fit(X, y)
935935
assert_array_equal(nca.components_, A)
@@ -940,7 +940,7 @@ def test_one_class(self):
940940
X = self.iris_points[self.iris_labels == 0]
941941
y = self.iris_labels[self.iris_labels == 0]
942942

943-
A = make_spd_matrix(X.shape[1], X.shape[1])
943+
A = make_spd_matrix(n_dim=X.shape[1], random_state=X.shape[1])
944944
nca = NCA(init=A, max_iter=30, n_components=X.shape[1])
945945
nca.fit(X, y)
946946
assert_array_equal(nca.components_, A)

test/test_mahalanobis_mixin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,12 @@ def test_init_mahalanobis(estimator, build_dataset):
503503
model.fit(input_data, labels)
504504

505505
# Initialize with a random spd matrix
506-
init = make_spd_matrix(X.shape[1], random_state=rng)
506+
init = make_spd_matrix(n_dim=X.shape[1], random_state=rng)
507507
model.set_params(**{param: init})
508508
model.fit(input_data, labels)
509509

510510
# init.shape[1] must match X.shape[1]
511-
init = make_spd_matrix(X.shape[1] + 1, X.shape[1] + 1)
511+
init = make_spd_matrix(n_dim=X.shape[1] + 1, random_state=rng)
512512
model.set_params(**{param: init})
513513
msg = ('The input dimensionality {} of the given '
514514
'mahalanobis matrix `{}` must match the '

0 commit comments

Comments
 (0)