Notes

Variable

A dataset is really just a structured way of recording “things that can vary” across people, houses, patients, or time. Each of those “things that can vary” is what statisticians call a variable.

What a variable is
A variable is a measurable attribute that can take different values across observations. If each row in a table is one house, then “sale price,” “number of bedrooms,” and “distance to downtown” are variables—because they differ from house to house. Variables can be:

  • Numerical: counts or measurements (income, temperature, blood pressure).
  • Categorical: group labels (neighborhood, diagnosis type, color).
  • Binary: yes/no categories (defaulted: true/false).
  • Ordinal: ordered categories (small/medium/large; pain level 1–5).

Variables in machine learning: features and labels
In ML, variables usually play one of two roles:

  • Features (inputs): variables used to make a prediction, like square footage and age of a house.
  • Label or target (output): the variable you want to predict, like sale price or whether a patient has a disease.

This distinction matters because training a model is essentially learning a relationship between feature variables and the target variable.

Why it matters (and what breaks without it)
Treating a variable incorrectly can quietly ruin an analysis or model:

  • Encoding a categorical variable as numbers (e.g., “red=1, blue=2”) can create fake “order” unless you use one-hot encoding.
  • Mixing scales across numerical variables can distort distance-based models (k-NN, k-means) unless you standardize.
  • Confusing a feature with the label can cause leakage, making performance look great until deployment.

Variable is a measurable attribute that can take different values across observations, such as age, temperature, or a class label. Variables are the basic units of statistical analysis and ML datasets, determining what relationships can be modeled and how uncertainty is quantified. In supervised learning, input variables are features and the target variable is the label; for example, predicting house price from square footage and location.

Think of a form you fill out online: it asks for your age, your city, and your favorite color. Each of those fields can take different values from person to person. In statistics and machine learning, each such field is called a variable.

A variable is simply something you measure, record, or describe about an item—like a person, a house, or a customer. For a house, variables might be number of bedrooms, price, and location. In AI/ML, variables are the pieces of information a model uses to learn patterns and make predictions.