Member-only story

Multi-Label Classification Example with MultiOutputClassifier and XGBoost in Python

Jack Dong
2 min readSep 16, 2020

--

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:

  1. Preparing the data
  2. Defining the model
  3. Predicting and accuracy check
  4. 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)

--

--

Responses (2)

Write a response