@@ -258,23 +258,6 @@ def is_string(s, target_str):
258
258
259
259
260
260
def _fit (self , X , y = None , sample_weight = None ):
261
- """Compute k-means clustering.
262
-
263
- Parameters
264
- ----------
265
- X : array-like or sparse matrix, shape=(n_samples, n_features)
266
- Training instances to cluster. It must be noted that the data
267
- will be converted to C ordering, which will cause a memory
268
- copy if the given data is not C-contiguous.
269
-
270
- y : Ignored
271
- not used, present here for API consistency by convention.
272
-
273
- sample_weight : array-like, shape (n_samples,), optional
274
- The weights for each observation in X. If None, all observations
275
- are assigned equal weight (default: None)
276
-
277
- """
278
261
init = self .init
279
262
if sklearn_check_version ("1.1" ):
280
263
if sklearn_check_version ("1.2" ):
@@ -447,26 +430,6 @@ def _daal4py_check_test_data(self, X):
447
430
448
431
449
432
def _predict (self , X , sample_weight = None ):
450
- """Predict the closest cluster each sample in X belongs to.
451
-
452
- In the vector quantization literature, `cluster_centers_` is called
453
- the code book and each value returned by `predict` is the index of
454
- the closest code in the code book.
455
-
456
- Parameters
457
- ----------
458
- X : {array-like, sparse matrix}, shape = [n_samples, n_features]
459
- New data to predict.
460
-
461
- sample_weight : array-like, shape (n_samples,), optional
462
- The weights for each observation in X. If None, all observations
463
- are assigned equal weight (default: None)
464
-
465
- Returns
466
- -------
467
- labels : array, shape [n_samples,]
468
- Index of the cluster each sample belongs to.
469
- """
470
433
check_is_fitted (self )
471
434
472
435
X = _daal4py_check_test_data (self , X )
@@ -614,86 +577,29 @@ def __init__(
614
577
615
578
@support_usm_ndarray ()
616
579
def fit (self , X , y = None , sample_weight = None ):
617
- """
618
- Compute k-means clustering.
619
-
620
- Parameters
621
- ----------
622
- X : {array-like, sparse matrix} of shape (n_samples, n_features)
623
- Training instances to cluster. It must be noted that the data
624
- will be converted to C ordering, which will cause a memory
625
- copy if the given data is not C-contiguous.
626
- If a sparse matrix is passed, a copy will be made if it's not in
627
- CSR format.
628
-
629
- y : Ignored
630
- Not used, present here for API consistency by convention.
631
-
632
- sample_weight : array-like of shape (n_samples,), default=None
633
- The weights for each observation in X. If None, all observations
634
- are assigned equal weight.
635
-
636
- .. versionadded:: 0.20
637
-
638
- Returns
639
- -------
640
- self : object
641
- Fitted estimator.
642
- """
643
580
return _fit (self , X , y = y , sample_weight = sample_weight )
644
581
645
- @support_usm_ndarray ()
646
- def predict (
647
- self , X , sample_weight = "deprecated" if sklearn_check_version ("1.3" ) else None
648
- ):
649
- """
650
- Predict the closest cluster each sample in X belongs to.
582
+ if sklearn_check_version ("1.5" ):
651
583
652
- In the vector quantization literature, `cluster_centers_` is called
653
- the code book and each value returned by ` predict` is the index of
654
- the closest code in the code book.
584
+ @ support_usm_ndarray ()
585
+ def predict ( self , X ):
586
+ return _predict ( self , X )
655
587
656
- Parameters
657
- ----------
658
- X : {array-like, sparse matrix} of shape (n_samples, n_features)
659
- New data to predict.
660
-
661
- sample_weight : array-like of shape (n_samples,), default=None
662
- The weights for each observation in X. If None, all observations
663
- are assigned equal weight.
588
+ else :
664
589
665
- Returns
666
- -------
667
- labels : ndarray of shape (n_samples,)
668
- Index of the cluster each sample belongs to.
669
- """
670
- return _predict (self , X , sample_weight = sample_weight )
590
+ @support_usm_ndarray ()
591
+ def predict (
592
+ self , X , sample_weight = "deprecated" if sklearn_check_version ("1.3" ) else None
593
+ ):
594
+ return _predict (self , X , sample_weight = sample_weight )
671
595
672
596
@support_usm_ndarray ()
673
597
def fit_predict (self , X , y = None , sample_weight = None ):
674
- """
675
- Compute cluster centers and predict cluster index for each sample.
676
-
677
- Convenience method; equivalent to calling fit(X) followed by
678
- predict(X).
679
-
680
- Parameters
681
- ----------
682
- X : {array-like, sparse matrix} of shape (n_samples, n_features)
683
- New data to transform.
684
-
685
- y : Ignored
686
- Not used, present here for API consistency by convention.
687
-
688
- sample_weight : array-like of shape (n_samples,), default=None
689
- The weights for each observation in X. If None, all observations
690
- are assigned equal weight.
691
-
692
- Returns
693
- -------
694
- labels : ndarray of shape (n_samples,)
695
- Index of the cluster each sample belongs to.
696
- """
697
598
return super ().fit_predict (X , y , sample_weight )
698
599
699
600
score = support_usm_ndarray ()(KMeans_original .score )
601
+
602
+ fit .__doc__ = KMeans_original .fit .__doc__
603
+ predict .__doc__ = KMeans_original .predict .__doc__
604
+ fit_predict .__doc__ = KMeans_original .fit_predict .__doc__
605
+ score .__doc__ = KMeans_original .score .__doc__
0 commit comments