File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Original file line number Diff line number Diff line change @@ -437,21 +437,24 @@ def test_minibatch_sensible_reassign(global_random_seed):
437
437
n_clusters = 20 , batch_size = 10 , random_state = global_random_seed , init = "random"
438
438
).fit (zeroed_X )
439
439
# there should not be too many exact zero cluster centers
440
- assert km .cluster_centers_ .any (axis = 1 ).sum () > 10
440
+ num_non_zero_clusters = km .cluster_centers_ .any (axis = 1 ).sum ()
441
+ assert num_non_zero_clusters > 9 , f"{ num_non_zero_clusters = } is too small"
441
442
442
443
# do the same with batch-size > X.shape[0] (regression test)
443
444
km = MiniBatchKMeans (
444
445
n_clusters = 20 , batch_size = 200 , random_state = global_random_seed , init = "random"
445
446
).fit (zeroed_X )
446
447
# there should not be too many exact zero cluster centers
447
- assert km .cluster_centers_ .any (axis = 1 ).sum () > 10
448
+ num_non_zero_clusters = km .cluster_centers_ .any (axis = 1 ).sum ()
449
+ assert num_non_zero_clusters > 9 , f"{ num_non_zero_clusters = } is too small"
448
450
449
451
# do the same with partial_fit API
450
452
km = MiniBatchKMeans (n_clusters = 20 , random_state = global_random_seed , init = "random" )
451
453
for i in range (100 ):
452
454
km .partial_fit (zeroed_X )
453
455
# there should not be too many exact zero cluster centers
454
- assert km .cluster_centers_ .any (axis = 1 ).sum () > 10
456
+ num_non_zero_clusters = km .cluster_centers_ .any (axis = 1 ).sum ()
457
+ assert num_non_zero_clusters > 9 , f"{ num_non_zero_clusters = } is too small"
455
458
456
459
457
460
@pytest .mark .parametrize (
You can’t perform that action at this time.
0 commit comments