Commit e9301ae
committed
feat(clustering): add random_state to KMeans and MiniBatchKMeans
Replaces the hardcoded random_state=42 with a parameter. Default stays at 42 for reproducibility; pass random_state=None for non-deterministic seeding.
Adds 3 tests per class covering default-seed reproducibility, explicit-seed reproducibility (labels and centers exact, inertia with rel=1e-5 for float32 BLAS ULPs), and None opt-in. docs/guide/analysis.md gets a short note. 588 CPU tests pass; 81 GPU tests pass under serial pytest-xdist.1 parent 446f45f commit e9301ae
3 files changed
Lines changed: 67 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
359 | 363 | | |
360 | 364 | | |
361 | 365 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
606 | 606 | | |
607 | 607 | | |
608 | 608 | | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
609 | 612 | | |
610 | 613 | | |
611 | 614 | | |
612 | 615 | | |
613 | 616 | | |
| 617 | + | |
614 | 618 | | |
615 | 619 | | |
616 | 620 | | |
| 621 | + | |
617 | 622 | | |
618 | 623 | | |
619 | 624 | | |
| |||
627 | 632 | | |
628 | 633 | | |
629 | 634 | | |
630 | | - | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
631 | 640 | | |
632 | 641 | | |
633 | 642 | | |
| |||
643 | 652 | | |
644 | 653 | | |
645 | 654 | | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
646 | 659 | | |
647 | 660 | | |
648 | 661 | | |
649 | 662 | | |
650 | 663 | | |
| 664 | + | |
651 | 665 | | |
652 | 666 | | |
653 | 667 | | |
654 | 668 | | |
| 669 | + | |
655 | 670 | | |
656 | 671 | | |
657 | 672 | | |
| |||
671 | 686 | | |
672 | 687 | | |
673 | 688 | | |
674 | | - | |
| 689 | + | |
675 | 690 | | |
676 | 691 | | |
677 | 692 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
637 | 637 | | |
638 | 638 | | |
639 | 639 | | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
640 | 667 | | |
641 | 668 | | |
642 | 669 | | |
| |||
668 | 695 | | |
669 | 696 | | |
670 | 697 | | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
671 | 717 | | |
672 | 718 | | |
673 | 719 | | |
| |||
0 commit comments