-1
を反復可能なされていないsklearn.model_selection 'KFold' オブジェクトは、私は次のコード</p> <p>このコードに問題がある
# simulate splitting a dataset of 25 observations into 5 folds
from sklearn.model_selection import KFold
kf = KFold(n_splits=5, random_state=None, shuffle=False)
# print the contents of each training and testing set
print('{} {:^61} {}'.format('Iteration',
'Training set observations',
'Testing set observations'))
for iteration, data in enumerate(kf, start=1):
print('{:^9} {} {!s:^25}'.format(iteration, data[0], data[1]))
はTypeError: 'KFold' オブジェクトが反復可能ではありません
TypeError Traceback (most recent call last)
<ipython-input-21-13995db0f7c7> in <module>()
5 # print the contents of each training and testing set
6 print('{} {:^61} {}'.format('Iteration', 'Training set
observations', 'Testing set observations'))
----> 7 for iteration, data in enumerate(kf, start=1):
8 print('{:^9} {} {!s:^25}'.format(iteration, data[0], data[1]))
TypeError: 'KFold' object is not iterable
に私のために必要な唯一の変更は十分ではなかったです元のコードは 'kf'ではなく' kf.split(X) 'です。 –