Skip to content

Commit a8970fc

Browse files
committed
Added Testcase for LDA-Covariance
1 parent 13c241f commit a8970fc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

sklearn/tests/test_lda.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,17 @@ def test_lda_scaling():
149149
# should be able to separate the data perfectly
150150
assert_equal(clf.fit(x, y).score(x, y), 1.0,
151151
'using covariance: %s' % solver)
152+
153+
154+
def test_covariance():
155+
x, y = make_blobs(n_samples=100, n_features=5,
156+
centers=1, random_state=42)
157+
158+
# make features correlated
159+
x = np.dot(x, np.arange(x.shape[1] ** 2).reshape(x.shape[1], x.shape[1]))
160+
161+
c_e = lda._cov(x, 'empirical')
162+
assert_almost_equal(c_e, c_e.T)
163+
164+
c_s = lda._cov(x, 'auto')
165+
assert_almost_equal(c_s, c_s.T)

0 commit comments

Comments
 (0)