File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -344,6 +344,22 @@ def test_minibatch_reassign():
344344 assert_greater (((centers_before - centers_after )** 2 ).sum (axis = 1 ).min (),
345345 .2 )
346346
347+ # Give a perfect initialization, with a small reassignment_ratio,
348+ # no center should be reassigned
349+ for this_X in (X , X_csr ):
350+ mb_k_means = MiniBatchKMeans (n_clusters = n_clusters , batch_size = 1 ,
351+ init = centers .copy (),
352+ random_state = 42 )
353+ mb_k_means .fit (this_X )
354+ centers_before = mb_k_means .cluster_centers_ .copy ()
355+ # Turn on verbosity to smoke test the display code
356+ _mini_batch_step (this_X , (X ** 2 ).sum (axis = 1 ),
357+ mb_k_means .cluster_centers_ ,
358+ mb_k_means .counts_ ,
359+ np .zeros (X .shape [1 ], np .double ),
360+ False , random_reassign = True , random_state = 42 ,
361+ reassignment_ratio = 1e-15 )
362+
347363
348364def test_sparse_mb_k_means_callable_init ():
349365
You can’t perform that action at this time.
0 commit comments