tss = TimeSeriesSplit(max_train_size=None, n_splits=10)
l =[]
neighb = [1,3,5,7,9,11,13,12,23,19,18]
for k in neighb:
knn = KNeighborsClassifier(n_neighbors=k, algorithm='brute')
sc = cross_val_score(knn, X1, y1, cv=tss, scoring='accuracy')
l.append(sc.mean())
Trying to use 10 fold TimeSeries Split, but in the documentation of cross_val_score, it is given that we need to pass a cross-validation generator or an iterable. How should I pass it after time series split into train and test data to cv
TypeError
Traceback (most recent call last)
in ()
14 for k in neighb:
15 knn = KNeighborsClassifier(n_neighbors=k, algorithm='brute')
---> 16 sc = cross_val_score(knn, X1, y1, cv=tss, scoring='accuracy')
17 l.append(sc.mean())
18 ~\Anaconda3\lib\site-packages\sklearn\cross_validation.py in cross_val_score(estimator, X, y, scoring, cv, n_jobs, verbose, fit_params, pre_dispatch)
1579 train, test, verbose, None, 1580 fit_params)
-> 1581 for train, test in cv)
1582 return np.array(scores)[:, 0]
1583
TypeError: 'TimeSeriesSplit' object is not iterable