Foundations

Parametric and Nonparametric Models Compared

Learn how models with a fixed parameter count differ from those that grow with data, in assumptions, cost, data needs and extrapolation.

Key takeaways

  • Parametric means a fixed-size description of the model, and nonparametric means the description can grow with the number of examples.
  • Nonparametric models still have settings, such as the number of neighbors or a bandwidth, that control how flexible they are.
  • A correct parametric form learns quickly, while a wrong one leaves an error that no amount of data removes.
  • Nonparametric methods need rapidly more data as the number of informative dimensions rises.
  • Neither family is safer outside the training range: one extends its assumed shape and the other tends to flatten or revert.

A parametric model has a fixed number of parameters chosen before it sees the data: more examples sharpen their values without adding new ones. A nonparametric model lets its effective complexity grow as the data grows, often by keeping examples around or adding structure to fit them.

The practical difference is a trade. Parametric models commit to a shape, which makes them compact and data-efficient when the shape is about right. Nonparametric models follow the data more freely, and pay in data, memory or prediction time.

Two ways to remember a dataset

Fit a straight line to a million points and you keep two numbers. You could discard the data and still make predictions. Everything the model learned must pass through the slope and intercept.

Use 5-nearest neighbors on the same million points and you keep them all. To predict at x, you find the five stored inputs closest to x and average their targets. The data is the model.

Fixed size or growing with the data
Parametric Fixed number of parameters Assumes a functional form Compact and quick to predict Error floor if the form is wrong Nonparametric Complexity can grow with n Weaker assumptions on shape Often stores or revisits data Hungry for data in many dimensions VS Parametric Fixed number of parameters Assumes a functional form Compact and quick to predict Error floor if the form is wrong Nonparametric Complexity can grow with n Weaker assumptions on shape Often stores or revisits data Hungry for data in many dimensions

Where familiar methods fall

Method Family What is kept after training
Linear and logistic regression Parametric One weight per feature, plus an intercept
Naive Bayes with fixed features Parametric Per-class feature statistics
Gaussian mixture, fixed number of components Parametric Weights, means, covariances
Neural network of fixed architecture Parametric in the strict sense A fixed set of weights
k-nearest neighbors Nonparametric The training examples
Kernel density estimate Nonparametric The training examples and a bandwidth
Kernel support vector machine Nonparametric Support vectors, whose number can grow with n
Gaussian process regression Nonparametric Training inputs and quantities computed from them
Decision tree grown without a size limit Nonparametric A tree that can deepen as data arrives

Neural networks show the limits of the labels. A given network is parametric, yet it may have so many parameters that it behaves much like a flexible nonparametric method. People also tend to pick a larger network when they have more data.

The name "nonparametric" misleads too. A Gaussian process has covariance settings to fit, and kernel density estimation lives or dies by its bandwidth. What is missing is a fixed-size summary of the function.

A small side-by-side

Suppose the data come from a rising curve and you have observations at inputs 1 through 5 with targets 2, 4, 6, 8 and 10.

A least squares line gives ŷ = 2x exactly. At x = 3.5 it predicts 7. At x = 10 it predicts 20.

A 2-nearest-neighbor regressor at x = 3.4 finds inputs 3 and 4 and predicts 7. At x = 10 it finds inputs 5 and 4 and predicts 9, and it will predict 9 at x = 1,000.

Inside the data, both are reasonable. Outside, they disagree sharply, and the data cannot say who is right. If the process really is linear, the line wins. If the quantity saturates at 10, the neighbor method is closer.

The flexibility dial

Both families have a way to trade smoothness against detail, but it lives in different places.

In a parametric model, you usually change flexibility by changing the form: add a squared term, an interaction or a layer. Each choice defines a new fixed-size model.

In a nonparametric model, a single smoothing setting often does the job. In k-nearest neighbors, k = 1 follows every point and k = n predicts the overall average. In kernel density estimation, a narrow bandwidth yields a spiky estimate and a wide one blurs everything into one hump.

For these methods to home in on the truth as data accumulates, the neighborhood has to shrink while still containing more and more points. For k-nearest neighbors the standard condition is that k grows without bound while k/n goes to zero. Keeping k fixed at 3 forever leaves the noise of 3 points in every prediction, however large the dataset.

Whatever the family, select these settings with validation data, and refit any scaling inside each training fold. Distances depend on feature units, so an unscaled column can quietly decide who counts as a neighbor.

Cost of training and prediction

For n training examples with d features, rough costs look like this:

Method Memory for the model Work for one prediction
Linear model About d numbers About d multiply-adds
Brute-force nearest neighbors About n × d numbers About n × d operations
Kernel model with s support vectors About s × d numbers About s × d operations
Single tree of depth k One node per split About k comparisons

With n = 1,000,000 and d = 100, brute-force neighbor search touches 100 million values per query, while the linear model touches 100. Index structures and approximate nearest neighbor search narrow the gap considerably. Trees show that nonparametric need not mean slow.

Training can be expensive too. Standard exact Gaussian process regression requires work that grows with the cube of n, so large datasets call for approximations.

How fast each learns

If a parametric form is correct and standard conditions hold, the expected squared error from estimation shrinks roughly in proportion to 1/n. Ten times the data gives about a tenth of that error.

Nonparametric rates are slower and depend on dimension. For estimating a regression function known only to be twice smoothly differentiable, the best achievable rate in general is of order n^(−4/(4+d)). Ignoring constants, cutting the error tenfold then takes about:

Informative dimensions d Data multiplier needed
1 About 18
4 100
10 About 3,200

This is a form of the curse of dimensionality. Real data often does better than these worst cases, because it concentrates near lower-dimensional structure or depends on only a few features.

The parametric advantage comes with the condition "if correct". Fit a line to a parabola and the error stops falling at whatever the best line achieves.

What happens where data is thin

Behavior in sparse regions is often the deciding difference.

A parametric model borrows strength from everywhere. Its prediction in a rarely seen corner is shaped by the dense regions through the shared parameters. That is helpful when the form is right and misleading when the corner obeys different rules, because nothing in the point prediction signals the problem.

A local nonparametric model relies on whatever is nearby. In a sparse corner, "nearby" may be far away, or consist of two noisy points. A Gaussian process handles this more openly by reporting wider uncertainty away from its training inputs, though that uncertainty is only as good as its covariance assumptions. Random forests cannot extrapolate beyond the target values they have averaged, which surprises people forecasting a growing quantity.

Before deploying either, find out how far typical new inputs lie from the training data, and decide what the system should do when one is far away: fall back to a rule, flag for review or decline to predict.

Choosing between them

Lean toward a parametric model when:

  • examples are scarce relative to the number of features,
  • theory or experience suggests the shape,
  • predictions must be fast or fit on a small device,
  • you need coefficients people can inspect, remembering that they describe the model and do not establish causes.

Lean toward a nonparametric or very flexible model when:

  • you have plenty of examples,
  • the relationship has thresholds, interactions or bends you cannot specify,
  • there is a meaningful notion of similarity between cases.

A middle path combines them. Semiparametric models keep a parametric part for the effects you understand and a flexible part for the rest. You can also fit a simple model first, then train a flexible one on its residuals.

Keeping training data inside a model has a side effect worth planning for: the saved artifact contains those records. If they are personal or licensed, storage, access and deletion duties travel with the model file. Rules differ by jurisdiction, so ask counsel where it matters.

Common questions

Is a random forest nonparametric?

It is usually treated that way, since its trees can grow larger as the dataset grows. If you cap depth and tree count tightly, its size stops growing, and the distinction becomes mostly a matter of how you tune it.

Can I compare them by counting parameters?

Not across families. A linear model's weights, a neighbor method's stored rows and a tree's split thresholds do different amounts of work. Some tools use an effective degrees of freedom, which measures how strongly the fitted values respond to the observed targets. For k-nearest neighbors on distinct inputs, each training target gets weight 1/k in its own fitted value, giving about n/k in total. A small k therefore behaves like a model with many parameters.

Which one overfits more?

Either can. A parametric model with far more parameters than examples can overfit badly without constraints. A nonparametric one with sensible smoothing may not. Check held-out error, as described in training error versus generalization error, and do not rely on the family name.

Written for 4MachineLearning with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 42 articles in Foundations →

Latest news on this topic