@@ -647,19 +647,19 @@ class HomogeneousTimeSeriesCV(_BaseKFold):
647
647
648
648
Parameters
649
649
----------
650
- n_folds : int, default=3
651
- Number of folds . Must be at least 2 .
650
+ n_splits : int, default=3
651
+ Number of splits . Must be at least 1 .
652
652
653
653
Examples
654
654
--------
655
655
>>> from sklearn.model_selection import HomogeneousTimeSeriesCV
656
656
>>> X = np.array([[1, 2], [3, 4], [1, 2], [3, 4]])
657
657
>>> y = np.array([1, 2, 3, 4])
658
- >>> htscv = HomogeneousTimeSeriesCV(n_folds=4 )
658
+ >>> htscv = HomogeneousTimeSeriesCV(n_splits=3 )
659
659
>>> htscv.get_n_splits(X)
660
660
3
661
661
>>> print(htscv) # doctest: +NORMALIZE_WHITESPACE
662
- HomogeneousTimeSeriesCV(n_folds=4 )
662
+ HomogeneousTimeSeriesCV(n_splits=3 )
663
663
>>> for train_index, test_index in htscv.split(X):
664
664
... print("TRAIN:", train_index, "TEST:", test_index)
665
665
... X_train, X_test = X[train_index], X[test_index]
@@ -672,11 +672,11 @@ class HomogeneousTimeSeriesCV(_BaseKFold):
672
672
-----
673
673
Size of each fold here is same as size of each fold split by KFold.
674
674
675
- Number of splitting iterations in this cross-validator, n_folds-1 ,
675
+ Number of splitting iterations in this cross-validator, n_splits ,
676
676
is not equal to other KFold based cross-validators'.
677
677
"""
678
- def __init__ (self , n_folds = 3 ):
679
- super (HomogeneousTimeSeriesCV , self ).__init__ (n_folds ,
678
+ def __init__ (self , n_splits = 3 ):
679
+ super (HomogeneousTimeSeriesCV , self ).__init__ (n_splits ,
680
680
shuffle = False ,
681
681
random_state = None )
682
682
@@ -706,12 +706,13 @@ def split(self, X, y=None, labels=None):
706
706
"""
707
707
X , y , labels = indexable (X , y , labels )
708
708
n_samples = _num_samples (X )
709
- if self .n_folds > n_samples :
709
+ n_splits = self .n_splits
710
+ n_folds = n_splits + 1
711
+ if n_folds > n_samples :
710
712
raise ValueError (
711
- ("Cannot have number of folds n_folds ={0} greater"
712
- " than the number of samples: {1}." ).format (self . n_folds ,
713
+ ("Cannot have number of folds ={0} greater"
714
+ " than the number of samples: {1}." ).format (n_folds ,
713
715
n_samples ))
714
- n_folds = self .n_folds
715
716
indices = np .arange (n_samples )
716
717
fold_sizes = (n_samples // n_folds ) * np .ones (n_folds , dtype = np .int )
717
718
fold_sizes [:n_samples % n_folds ] += 1
@@ -741,7 +742,7 @@ def get_n_splits(self, X=None, y=None, labels=None):
741
742
n_splits : int
742
743
Returns the number of splitting iterations in the cross-validator.
743
744
"""
744
- return self .n_folds - 1
745
+ return self .n_splits
745
746
746
747
747
748
class LeaveOneLabelOut (BaseCrossValidator ):
0 commit comments