Member-only story
Multi-Label Classification Example with MultiOutputClassifier and XGBoost in Python

Scikit-learn API provides a MulitOutputClassifier class that helps to classify multi-output data. In this tutorial, we’ll learn how to classify multi-output (multi-label) data with this method in Python. Multi-output data contains more than one y label data for a given X input data. The tutorial covers:
- Preparing the data
- Defining the model
- Predicting and accuracy check
- Source code listing
We’ll start by loading the required libraries for this tutorial.
Preparing the data
We can generate a multi-output data with a make_multilabel_classification function. The target dataset contains 20 features (x), 5 classes (y), and 10000 samples.
We’ll define them in the parameters of the function.
x, y = make_multilabel_classification(n_samples=10000, n_features=20, n_classes=5, random_state=88)