cheatsheet

Scikit-learn Cheatsheet: Multioutput

Multioutput (also known as multitarget or multiresponse) regression and classification involves predicting multiple target variables for each sample.

What can be done?

Key Strategies

  1. MultiOutputRegressor / MultiOutputClassifier:
    • Independently fits one regressor/classifier per target.
    • Simple baseline that assumes targets are independent.
  2. RegressorChain / ClassifierChain:
    • Arranges estimators in a chain.
    • Target $i$ is predicted using the input features plus the predictions of targets $0, \dots, i-1$.
    • Captures correlations between targets.

Data Format

Code Snippet: Multioutput Regression & Chains

from sklearn.multioutput import MultiOutputRegressor, RegressorChain
from sklearn.ensemble import RandomForestRegressor
import numpy as np

# Multi-target data (X: 100x10, Y: 100x3)
X = np.random.randn(100, 10)
Y = np.random.randn(100, 3)

# 1. Independent Multioutput
mor = MultiOutputRegressor(RandomForestRegressor())
mor.fit(X, Y)

# 2. Regressor Chain (captures target dependencies)
chain = RegressorChain(RandomForestRegressor())
chain.fit(X, Y)
Y_pred = chain.predict(X_new)

Credits: This cheatsheet is based on the scikit-learn documentation and examples, which are licensed under the BSD 3-Clause License. Copyright (c) 2007 - 2026 The scikit-learn developers. All rights reserved.