Skip to content

Commit 8117795

Browse files
committed
CUR feature selection test
1 parent a1ce772 commit 8117795

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_feature_simple_cur.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@ def test_non_it(self):
4646

4747
self.assertTrue(np.allclose(selector.selected_idx_, ref_idx))
4848

49+
def test_unique_selected_idx_zero_score(self):
50+
"""
51+
Tests that the selected idxs are unique, which may not be the
52+
case when the score is numerically zero
53+
"""
54+
np.random.seed(0)
55+
n_samples = 10
56+
n_features = 15
57+
X = np.random.rand(n_samples, n_features)
58+
X[:, 3] = np.random.rand(10) * 1e-13
59+
X[:, 4] = np.random.rand(10) * 1e-13
60+
selector_problem = CUR(n_to_select=len(X.T)).fit(X)
61+
assert len(selector_problem.selected_idx_) == len(
62+
set(selector_problem.selected_idx_)
63+
)
64+
4965

5066
if __name__ == "__main__":
5167
unittest.main(verbosity=2)

0 commit comments

Comments
 (0)