How do you define the target variable for a machine learning problem?
Defining the target variable means deciding exactly what outcome the machine learning model should learn to predict.
A good target should turn the business objective into a clear, measurable value for each training sample.
Start with the business outcome
Ask what result actually matters.
For example:
- customer churn
- loan default
- product demand
- delivery time
- transaction fraud
Then convert that outcome into something the dataset can represent consistently.
Make the target precise
A target should answer questions such as:
- What exactly is being predicted?
- For which sample or entity?
- Over what time period?
- How will the outcome be measured?
For example, instead of defining the target vaguely as:
Will the customer leave?define it more precisely:
Did the customer cancel the subscription within the next 30 days?This can be represented as:
1= customer churned within 30 days0= customer did not churn within 30 days
Match the target to the prediction task
The form of the target depends on what the model needs to predict.
- A categorical target is commonly used for classification.
- A numerical target is commonly used for regression.
- A future numerical value over time may define a forecasting target.
Use information that becomes known after the prediction point
The target usually represents an outcome that occurs after the moment when the prediction is made.
For example, if a churn prediction is made on January 1, the target may record whether the customer churns during the following 30 days.
However, the model's input features should not include information from that future period. Otherwise, the training data may contain target leakage.
Make sure the target is reliable
A useful target should be:
- clearly defined
- measurable from available data
- consistent across samples
- closely connected to the real business objective
- available for enough historical examples to train and evaluate the model
If the target is poorly defined, the model may learn to optimize the wrong outcome even if its technical metrics look good.
In short, define the target variable by translating the business goal into a precise, measurable outcome for each sample, with a clear prediction point and time horizon.
Learning Sequence
Machine Learning Curriculum
How do you choose useful input features for a machine learning problem?
Explore Related Questions
Deepen your understanding across related Machine Learning topics.