I am using a large dataset with 4 different multilabel classes. I was trying to apply Random forest algorithm on those data set. After preparing data set I separate X (feature columns) and Y(feature class), split those data into train and testing data, fit training data to model, predict test data and was trying to find the accuracy by using testing data then I faced valueError: 'multiclass-multioutput is not supported'. My data set is:


enter image description here

And here is my code after pre-processing:

#define X and y feature_cols=['MFCCs_ 1','MFCCs_ 2','MFCCs_ 3','MFCCs_ 4','MFCCs_ 5','MFCCs_ 6','MFCCs_ 7','MFCCs_ 8','MFCCs_ 9', 'MFCCs_10', 'MFCCs_11', 'MFCCs_12', 'MFCCs_13','MFCCs_14','MFCCs_15','MFCCs_16','MFCCs_17','MFCCs_18','MFCCs_19','MFCCs_20','MFCCs_21','MFCCs_22'] feature_class=['RecordID','Family','Genus','Species']

# X is a matrix, hence we use [] to access the features we want in feature_cols X = train[feature_cols]

# y is a vector, hence we use dot to access 'label' y = train[feature_class]

model= RandomForestClassifier(n_estimators=100) X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.30,random_state=42) model.fit(X_train, y_train) preds = model.predict(X_test) print(accuracy_score(y_test, preds,normalize=False))

and then I faced these value error: enter image description here

How could I solve these problem?


2 Answers 2


From the documentation:

Warning: At present, no metric in sklearn.metrics supports the multioutput-multiclass classification task.

See here and also this issue. Multiclass-multioutput doesn't seem reliably implemented at this point.


The error is because Scikit-learn RandomForestClassifier does not support multiple outputs with N-classes per output. For multi-output only binary classification is supported.

Instead train separate models with single targets. For instance one model with 'Species'. Or you could concatenate Family, Genus, Species to get a full species name and use that as the target.

RecordId sounds like it should not be used as a target.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.