@@ -87,9 +87,9 @@ def test_incremental_pca_sparse(sparse_container):
87
87
ipca .partial_fit (X_sparse )
88
88
89
89
90
- def test_incremental_pca_check_projection ():
90
+ def test_incremental_pca_check_projection (global_random_seed ):
91
91
# Test that the projection of data is correct.
92
- rng = np .random .RandomState (1999 )
92
+ rng = np .random .RandomState (global_random_seed )
93
93
n , p = 100 , 3
94
94
X = rng .randn (n , p ) * 0.1
95
95
X [:10 ] += np .array ([3 , 4 , 5 ])
@@ -108,9 +108,9 @@ def test_incremental_pca_check_projection():
108
108
assert_almost_equal (np .abs (Yt [0 ][0 ]), 1.0 , 1 )
109
109
110
110
111
- def test_incremental_pca_inverse ():
111
+ def test_incremental_pca_inverse (global_random_seed ):
112
112
# Test that the projection of data can be inverted.
113
- rng = np .random .RandomState (1999 )
113
+ rng = np .random .RandomState (global_random_seed )
114
114
n , p = 50 , 3
115
115
X = rng .randn (n , p ) # spherical data
116
116
X [:, 1 ] *= 0.00001 # make middle component relatively small
@@ -217,9 +217,9 @@ def test_incremental_pca_num_features_change():
217
217
ipca .partial_fit (X2 )
218
218
219
219
220
- def test_incremental_pca_batch_signs ():
220
+ def test_incremental_pca_batch_signs (global_random_seed ):
221
221
# Test that components_ sign is stable over batch sizes.
222
- rng = np .random .RandomState (1999 )
222
+ rng = np .random .RandomState (global_random_seed )
223
223
n_samples = 100
224
224
n_features = 3
225
225
X = rng .randn (n_samples , n_features )
@@ -254,9 +254,9 @@ def test_incremental_pca_partial_fit_small_batch():
254
254
assert_allclose (pca .components_ , pipca .components_ , atol = 1e-3 )
255
255
256
256
257
- def test_incremental_pca_batch_values ():
257
+ def test_incremental_pca_batch_values (global_random_seed ):
258
258
# Test that components_ values are stable over batch sizes.
259
- rng = np .random .RandomState (1999 )
259
+ rng = np .random .RandomState (global_random_seed )
260
260
n_samples = 100
261
261
n_features = 3
262
262
X = rng .randn (n_samples , n_features )
@@ -286,9 +286,9 @@ def test_incremental_pca_batch_rank():
286
286
assert_allclose_dense_sparse (components_i , components_j )
287
287
288
288
289
- def test_incremental_pca_partial_fit ():
289
+ def test_incremental_pca_partial_fit (global_random_seed ):
290
290
# Test that fit and partial_fit get equivalent results.
291
- rng = np .random .RandomState (1999 )
291
+ rng = np .random .RandomState (global_random_seed )
292
292
n , p = 50 , 3
293
293
X = rng .randn (n , p ) # spherical data
294
294
X [:, 1 ] *= 0.00001 # make middle component relatively small
@@ -316,9 +316,9 @@ def test_incremental_pca_against_pca_iris():
316
316
assert_almost_equal (np .abs (Y_pca ), np .abs (Y_ipca ), 1 )
317
317
318
318
319
- def test_incremental_pca_against_pca_random_data ():
319
+ def test_incremental_pca_against_pca_random_data (global_random_seed ):
320
320
# Test that IncrementalPCA and PCA are approximate (to a sign flip).
321
- rng = np .random .RandomState (1999 )
321
+ rng = np .random .RandomState (global_random_seed )
322
322
n_samples = 100
323
323
n_features = 3
324
324
X = rng .randn (n_samples , n_features ) + 5 * rng .rand (1 , n_features )
@@ -348,10 +348,10 @@ def test_explained_variances():
348
348
assert_almost_equal (pca .noise_variance_ , ipca .noise_variance_ , decimal = prec )
349
349
350
350
351
- def test_singular_values ():
351
+ def test_singular_values (global_random_seed ):
352
352
# Check that the IncrementalPCA output has the correct singular values
353
353
354
- rng = np .random .RandomState (0 )
354
+ rng = np .random .RandomState (global_random_seed )
355
355
n_samples = 1000
356
356
n_features = 100
357
357
@@ -360,7 +360,7 @@ def test_singular_values():
360
360
)
361
361
362
362
pca = PCA (n_components = 10 , svd_solver = "full" , random_state = rng ).fit (X )
363
- ipca = IncrementalPCA (n_components = 10 , batch_size = 100 ).fit (X )
363
+ ipca = IncrementalPCA (n_components = 10 , batch_size = 150 ).fit (X )
364
364
assert_array_almost_equal (pca .singular_values_ , ipca .singular_values_ , 2 )
365
365
366
366
# Compare to the Frobenius norm
@@ -382,7 +382,7 @@ def test_singular_values():
382
382
)
383
383
384
384
# Set the singular values and see what we get back
385
- rng = np .random .RandomState (0 )
385
+ rng = np .random .RandomState (global_random_seed )
386
386
n_samples = 100
387
387
n_features = 110
388
388
0 commit comments