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())
尝试使用10倍TimeSeries Split,但在cross_val_score的文档中,我们需要传递交叉验证生成器或迭代。在将时间序列分成火车和测试数据到cv
后,我应该如何传递它类型错误
追溯(最近的呼叫最后)
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年火车,测试,详细,无,
1580 fit_params)
- > 1581用于火车,在cv中测试)
1582返回np.array(得分)[:,0]
1583
TypeError:'TimeSeriesSplit'对象不可迭代