Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit abd1597

Browse filesBrowse files
authored
FIX Converted output to int64 in random_projection *_min_dim (#19374)
1 parent f4ed4c1 commit abd1597
Copy full SHA for abd1597

File tree

2 files changed

+9
-1
lines changed
Filter options

2 files changed

+9
-1
lines changed

‎sklearn/random_projection.py

Copy file name to clipboardExpand all lines: sklearn/random_projection.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def johnson_lindenstrauss_min_dim(n_samples, *, eps=0.1):
129129
% n_samples)
130130

131131
denominator = (eps ** 2 / 2) - (eps ** 3 / 3)
132-
return (4 * np.log(n_samples) / denominator).astype(int)
132+
return (4 * np.log(n_samples) / denominator).astype(np.int64)
133133

134134

135135
def _check_density(density, n_features):

‎sklearn/tests/test_random_projection.py

Copy file name to clipboardExpand all lines: sklearn/tests/test_random_projection.py
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,11 @@ def test_works_with_sparse_data():
352352
random_state=1).fit(sp.csr_matrix(data))
353353
assert_array_almost_equal(densify(rp_dense.components_),
354354
densify(rp_sparse.components_))
355+
356+
357+
def test_johnson_lindenstrauss_min_dim():
358+
"""Test Johnson-Lindenstrauss for small eps.
359+
360+
Regression test for #17111: before #19374, 32-bit systems would fail.
361+
"""
362+
assert johnson_lindenstrauss_min_dim(100, eps=1e-5) == 368416070986

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.