I am using different cross validation method. I first use k fold method on my code and it was perfectly well but when I use repeatedstratifiedkfold
method it gives me this error
TypeError: Singleton array array(None, dtype=object) cannot be considered a valid collection.
Can any one help me in this regard. Below is the minimal code that produces the issue.
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]
Here is the full trackback -
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
for train, test in ss.split(X):
File "C:\Users\anaconda3\lib\site-packages\sklearn\model_selection\_split.py", line 1201, in split
for train_index, test_index in cv.split(X, y, groups):
File "C:\Users\anaconda3\lib\site-packages\sklearn\model_selection\_split.py", line 731, in split
y = check_array(y, ensure_2d=False, dtype=None)
File "C:\Users\anaconda3\lib\site-packages\sklearn\utils\validation.py", line 63, in inner_f
return f(*args, **kwargs)
File "C:\Users\anaconda3\lib\site-packages\sklearn\utils\validation.py", line 667, in check_array
n_samples = _num_samples(array)
File "C:\Users\anaconda3\lib\site-packages\sklearn\utils\validation.py", line 202, in _num_samples
raise TypeError("Singleton array %r cannot be considered"
TypeError: Singleton array array(None, dtype=object) cannot be considered a valid collection.
F-E.mat
file that you have. You can instead replace that with a random numpy array of the same shape that gives the same error. – Garrido