Skip to content
ML Visualization

What Is a Model?

FoundationsBeginner~5 min

What Is a Model?A machine learning model is a mathematical function with adjustable parameters that maps inputs to predictions. Training a model means choosing the parameters that best fit observed data.

A machine learning model is just a function — it takes in numbers and spits out a prediction. The trick is finding the function that fits your data best.

  • Data points
  • Model
  • Residuals
  • True signal

The fitted numbers (3 of them — this is the whole model)

  • w0 · 1 (intercept)-7.0225
  • w1 · x12.1774
  • w2 · -2.7165

Model controls

Data
Shape of the data

A bending signal: no straight line can follow it, whatever numbers you fit.

24
1.0×
Model
Function family

The family is the shape you allow. Fitting only chooses the 3 numbers inside it.

Error (all points)3759.685
Numbers fitted3
Playback
Step 0 / 21
Speed
  1. Pick a family
  2. Fit the numbers
  3. Predict

Step 0 of 21 — Quadratic needs 3 numbers, and 3 points pin them exactly — error on those points is 0.000, and the model has learned nothing

Hollow points are ones the fit has not been shown yet. Drag any point on the plot and every fitted number moves with it.

Break it

The idea in plain words

A model is a function with adjustable knobs. You feed it an input and it returns a prediction; “training” means turning the knobs until the predictions line up with the data you’ve actually seen. Slide the complexity control: a flat constant can’t follow any trend, a line can follow a slope, and a curve can bend to the data.

A too-simple model leaves a visible, systematic gap — underfitting. How we measure that gap is the job of a loss function, and the simplest useful model is linear regression.

Now, the math

A polynomial model of degree d predicts:

y^=c0+c1x+c2x2++cdxd\hat{y} = c_0 + c_1 x + c_2 x^2 + \dots + c_d x^d
y^\hat{y}
the model’s predicted output.
xx
the input feature.
cic_i
the coefficients (the knobs) chosen during training.
dd
the degree — how much the curve can bend.
Show the derivation

For each degree, training picks the coefficients that minimize total squared error — a problem with a clean closed-form solution for polynomials. Degree 0 forces every coefficient except c0c_0 to zero, so the model can only output a single constant, no matter the input.

Trace it by hand

Take a tiny dataset of three points: (1, 2), (2, 3) and (3, 5). We train two models on it by least squares — a degree-0 constant and a degree-1 line — and score both with mean squared error. Values are rounded to 2 decimals (MSE to 3).

  1. The data and the two candidate models

    data: (1,2), (2,3), (3,5)y^=c0    vs    y^=c0+c1x\text{data: } (1,2),\ (2,3),\ (3,5) \qquad \hat{y} = c_0 \;\;\text{vs}\;\; \hat{y} = c_0 + c_1 x

    The only difference between the two models is one extra knob: the slope.

  2. Degree 0: the best constant is the mean

    c0=yˉ=2+3+53=3.33,MSE=1.56c_0 = \bar{y} = \frac{2 + 3 + 5}{3} = 3.33, \qquad \mathrm{MSE} = 1.56

    With zero degrees of freedom in x, least squares can do no better than predict the average everywhere.

  3. Degree 1: fit the slope and intercept

    c1=i(xixˉ)(yiyˉ)i(xixˉ)2=32=1.5,c0=yˉc1xˉ=0.33c_1 = \frac{\sum_i (x_i - \bar{x})(y_i - \bar{y})}{\sum_i (x_i - \bar{x})^2} = \frac{3}{2} = 1.5, \qquad c_0 = \bar{y} - c_1\bar{x} = 0.33

    x-bar is 2 and y-bar is 3.33, so the numerator sums to 3 and the denominator to 2.

  4. The line's predictions

    y^=0.33+1.5x:y^(1)=1.83,y^(2)=3.33,y^(3)=4.83\hat{y} = 0.33 + 1.5x: \quad \hat{y}(1) = 1.83, \quad \hat{y}(2) = 3.33, \quad \hat{y}(3) = 4.83

    Residuals against the actual 2, 3, 5 are 0.17, minus 0.33, and 0.17.

  5. Score the line

    MSE=(0.17)2+(0.33)2+(0.17)230.056\mathrm{MSE} = \frac{(0.17)^2 + (-0.33)^2 + (0.17)^2}{3} \approx 0.056

    Compare with 1.56 for the constant: same data, same loss, one more knob.

What just happened: Turning one extra knob — the slope — dropped MSE from 1.56 to 0.056, a factor of 28. A model is just a function with adjustable knobs, and training is choosing the knob values that shrink the measured gap to the data.

Now Break It

Try this: Fit a flat horizontal line to clearly curved data — show the systematic error that a too-simple model produces.

Control: Model complexity selector (set to "constant")

What happens: Systematic error: the model is too simple to capture the pattern in the data.

Where what is a model? is used

A model is a function fit to data, and that single idea powers products people use every day. When Gmail sorts a message into spam or primary, a classification model maps the words, sender, and headers to a probability. When Zillow estimates a home price or a bank sets a credit limit, a regression model turns features like square footage, location, and payment history into a number. Netflix and Spotify recommendations, weather forecasts, medical imaging triage, and the autocomplete in your phone keyboard are all models: functions whose parameters were chosen so their outputs match observed data. The domain and the math differ, but the recipe is constant. Collect examples, pick a family of functions, and tune it until predictions line up with reality.

A frequent misconception is that a model stores or memorizes the training data like a lookup table. In reality a model compresses patterns into parameters; it generalizes to inputs it has never seen precisely because it does not keep every example. A model that truly memorized would fail on anything new. A second pitfall is treating a model as objective truth. A model only reflects the data it was fit to, so biased, stale, or unrepresentative data produces confidently wrong predictions. If a hiring model learns from past decisions that favored one group, it will reproduce that bias. Understanding what a model is, a fitted function and nothing more, keeps you skeptical about both its accuracy and its fairness.

Frequently asked questions

What is a machine learning model in simple terms?
A model is a mathematical function that takes inputs, such as the pixels of an image or the features of a house, and produces an output like a label or a number. Its internal values, called parameters, are adjusted using example data so the outputs match reality as closely as possible. Once fit, the model can make predictions on new inputs it has never seen.
What is the difference between a model and an algorithm?
An algorithm is the procedure used to fit the model, such as gradient descent or a decision-tree splitting rule. The model is the resulting function with its learned parameters. In short, the algorithm is the process of learning and the model is the product of that learning.
Does a model just memorize the training data?
No. A useful model compresses patterns from the data into a relatively small set of parameters rather than storing every example. This compression is what lets it generalize to new inputs. A model that only memorized would perform well on training data but fail on anything new, a failure mode known as overfitting.
What does it mean to fit a model?
Fitting means adjusting the model's parameters so its predictions are as close as possible to the known answers in the training data. This is usually done by minimizing a loss function that measures how wrong the predictions are. After fitting, the parameters are frozen and the model is used to predict on fresh inputs.
Can a model be wrong even if it is well trained?
Yes. A model can only reflect the data it was fit to, so if that data is biased, outdated, or missing important cases, the model's predictions will be flawed even when training went smoothly. Models also make confident errors on inputs that differ from anything they saw during training. Good practice includes testing on held-out data and monitoring performance after deployment.

Written & reviewed by the ML Visualization team · Last updated .