我正在使用不同的交叉验证方法。我首先在我的代码上使用 k Fold 方法,效果非常好,但是当我使用repeatedstratifiedkfold方法时,它给了我这个错误
TypeError: Singleton array array(None, dtype=object) cannot be considered a valid collection.
Run Code Online (Sandbox Code Playgroud)
任何人都可以在这方面帮助我吗?以下是产生该问题的最少代码。
import numpy as np
from sklearn.model_selection import RepeatedStratifiedKFold
ss = RepeatedStratifiedKFold(n_splits=5, n_repeats=2, random_state=0)
X = np.random.rand(100, 5)
y = np.random.rand(100, 1)
for train_index, test_index in ss.split(X):
X_train, X_test = X[train_index], X[test_index]
y_train, y_test = y[train_index], y[test_index]
Run Code Online (Sandbox Code Playgroud)
这是完整的引用 -
start
Traceback (most recent call last):
File "C:\Users\full details of final year project\AZU\test_tace_updated.py", line 81, in <module>
main()
File "C:\Users\AZU\test_tace_updated.py", line 54, in main …Run Code Online (Sandbox Code Playgroud)