TypeError: '(array([ 2, 4, 6, ..., 3495, 3497, 3498]), slice(None, None, None))' is an invalid key
I am not sure why this error occurs, the first thing i can think sk-multilearn accept data in a specific format.
from skmultilearn.model_selection import iterative_train_test_split
X_train, y_train, X_test, y_test = iterative_train_test_split(X, y, test_size = 0.5)
The shape of X and y variable is ((3500, 7), (3500, 8))
Y variable has 8 columns, each one represent a class.
C1 C2 C3 C4 C5 C6 C7 C8
0 0 0 0 0 0 0 1
1 0 0 1 0 0 0 0
0 1 0 1 0 1 0 0
any idea how can i resolve this issue
I faced the same issue. You can see, that the source code uses the old pandas subsetting. If you reimplement the function and add .loc it works fine:
from skmultilearn.model_selection import IterativeStratification
stratifier = IterativeStratification(n_splits=2, order=2, sample_distribution_per_fold=[0.25, 0.75])
train_indexes, test_indexes = next(stratifier.split(X, y))
X_train, y_train = X.loc[train_indexes], y.loc[train_indexes]
X_test, y_test = X.loc[test_indexes], y.loc[test_indexes]
What is n_splits=2, order=2?
I faced the same issue. You can see, that the source code uses the old
pandassubsetting. If you reimplement the function and add.locit works fine:from skmultilearn.model_selection import IterativeStratification stratifier = IterativeStratification(n_splits=2, order=2, sample_distribution_per_fold=[0.25, 0.75]) train_indexes, test_indexes = next(stratifier.split(X, y)) X_train, y_train = X.loc[train_indexes], y.loc[train_indexes] X_test, y_test = X.loc[test_indexes], y.loc[test_indexes]
Thank you! This worked for us