← AI Terminology
Variables
Variables are named containers for data values in a model or programme — in statistics and ML, they refer specifically to measurable quantities that can differ across observations.
The term bridges mathematics, statistics, and programming: it means "something that varies and can be measured or assigned."
The term bridges mathematics, statistics, and programming: it means "something that varies and can be measured or assigned."
Why It Matters in AI
Distinguishing variable types (independent vs dependent, continuous vs categorical) shapes every modelling decision — which algorithm to use, how to encode inputs, and how to interpret outputs. In code, variables hold the tensors, weights, and gradients that define a neural network. Confusing the roles of variables (e.g. accidentally treating the target as a predictor) is one of the most common and costly modelling errors.
Key Points
| Aspect | Description |
|---|---|
| In code | Python variables (x = 5), PyTorch nn.Parameter (learned weights), JAX pytrees |
| Continuous | Takes any numeric value in a range (e.g. price, temperature) |
| Categorical | Takes one of a fixed set of labels (e.g. country, sentiment class) |
| Latent variable | Not directly observed — inferred by the model (e.g. a topic in LDA, a hidden state in an RNN) |
| Dependent variable | Target / label / response — what the model is trying to predict |
| Independent variable | Input / predictor / feature — what the model is given |
Simple Analogy
In a recipe, ingredients are independent variables (you control them) and the taste of the dish is the dependent variable (what results). A variable is simply "a slot you can put a different value into" — whether that slot holds a stock price, a pixel brightness, or a model weight.
Common Usage Examples
X, y = df.drop('target', axis=1), df['target']— splitting into independent and dependent variablestorch.nn.Parametercreates a learnable variable (weight) inside a neural network- Latent variables in a Variational Autoencoder (VAE) encode compressed representations of input data
- Categorical variable encoding:
LabelEncoderorOneHotEncoderin scikit-learn - Confounding variable: an unmeasured variable that distorts the apparent relationship between predictors and target
Summary
In short: In ML, "variable" usually means either a column of data (statistical sense) or a named value in code (programming sense) — context tells you which.