Glossary
What is a target variable?
In short
A target variable is the value a machine learning model learns to predict: whether a customer will leave, how much product will sell, how much a flat costs.
Machine learning · target variable
MMOOZZGG.com editorsChecked: 1 min read
For a child
Imagine you play “hot and cold” and look for a hidden toy. The toy is the goal. All the hints exist only to help you find it. When a computer learns, it is also shown what exactly it must find or guess: for example, whether it will rain tomorrow. That hidden answer is called the target variable.
In plain words
Every task for a model has a question it must answer. The answer to that question is the target variable. For training, people collect past cases where the answer is already known: customers who left or stayed, days with known sales. The model learns how the answer relates to the other data and then guesses it where it is still unknown. The answer can be a word from a list, such as “will leave” or “will stay”, or a number, such as revenue for a week. Analysts often call it the target or the label.
For business
Choosing what to predict is a management decision, not a technical one. It decides what value the model will bring. The task “predict churn” sounds clear, but it needs detail: leaving within a month or a quarter, and whether a customer who simply buys less often counts as gone. A badly worded task gives a model that accurately predicts something you do not need. The second risk: training needs a history where the answer is already known, and often there is none or it was recorded carelessly. Before you pay for a model, check that the metric you need has been recorded in your CRM or accounting system for long enough. For demand forecasting, this is usually sales by day and by product.
For a specialist
A target variable is the dependent variable in supervised learning that the model approximates as a function of the features; in scikit-learn it is passed as y to the fit method. The library’s glossary lists synonyms: dependent variable, response variable, ground truth, label. By target type, tasks are binary and multiclass classification, multilabel, regression, multi-output regression, ranking and time series forecasting. The target type sets the loss function and the metrics: cross-entropy and ROC-AUC for classes, MSE and MAE for numbers. The target is often transformed: skewed amounts are log-transformed, values are binarized at a threshold. The main risks are target leakage, when a feature indirectly contains the answer, and label noise. The scikit-learn documentation on common pitfalls advises splitting the data into training and test parts first, and only then fitting any transformations.
Do not confuse. Do not confuse it with targeting in advertising: there the word means showing ads to a chosen audience.
Example
A coffee shop chain wants to plan milk purchases. The target variable: milk use in liters for each location for tomorrow. The features are the day of the week, the weather, holidays and sales of past weeks.
Related terms
Questions and answers
Sources
Not sure whether your company needs this?
AI solutions map