# Multi Target Prediction

In this blog, lets talk about multi target variables. In a generic machine learning model prediction scenario, where we will have input features and single target variable.

Input Feature Output Feature
x1 , x2 , x3 , x4… y

Assigning multiple target variables would throw an error on linear regression ,Since it is incompatible with multiple target variable.

Input Feature Output Feature
x1 , x2 , x3 , x4….. y1 , y2 , y3 , y4 …..

Linear regression expect the output target variable to be a single value. But in a multiple target variable scenario, it is an array of multiple target variables. Hence it throws an error.

#### Random Forest model can predict Multi target Variables

We can use random forest to predict Mutiple target variables. The training methodology and syntax remains identical. The output target will be an array. This array contains multiple target variables to be predicted.

Theres’s a difference in the internal algorithm during multi target than that from single target variable. For this particular example, let’s consider a regression problem.

Let’s discuss of two method that is:

1. Stacked single target.

2. Ensemble of regressor chain.

### Stacked Single Target ​ Image from Springer Article by Grigorios Tsoumakas , William Groves , Ioannis Vlahavas

##### The above image describes how multi target variables are handled in stacked single target approach.
• The input variable is trained to predict the first variable Y1 from the Target variable array. This creates a predictor output function h1.

• This procedure is carried out on every variable from the target variable array. Their corresponding predictor output functions h1 , h2 ….hm.

• Next stage is the meta - variable generation, The input X is passed to the predictor function, which predicts an intermediate value i.e

• The second training stage takes

• On the Prediction side, The prediction function is deduced from the first training stage

• The number of first prediction stage output will be same as the number of multi target vector.

• The final predictions will be

### Ensemble of regressor chain

The name suggests, there is a chain pattern in predicting the multi target variable. ###### Image from Springer Article by Grigorios Tsoumakas , William Groves , Ioannis Vlahavas

• The input features and first target from the multi target array is used as label. The output will be a predictor function.

• Each target in Multi target array, produce respective prediction function

• On the Prediction side,

We have unwraped the working of Multi Target Prediction in Machine Learning. Please find the resources below for additive information.