What is a parametric machine learning algorithm and how is it different from a nonparametric machine learning algorithm?

In this post you will discover the difference between parametric and nonparametric machine learning algorithms.

Let’s get started.

## Learning a Function

Machine learning can be summarized as learning a function (f) that maps input variables (X) to output variables (Y).

Y = f(x)

An algorithm learns this target mapping function from training data.

The form of the function is unknown, so our job as machine learning practitioners is to evaluate different machine learning algorithms and see which is better at approximating the underlying function.

Different algorithms make different assumptions or biases about the form of the function and how it can be learned.

## Get your FREE Algorithms Mind Map

I've created a handy mind map of 60+ algorithms organized by type.

Download it, print it and use it.

Also get exclusive access to the machine learning algorithms email mini-course.

## Parametric Machine Learning Algorithms

Assumptions can greatly simplify the learning process, but can also limit what can be learned. Algorithms that simplify the function to a known form are called parametric machine learning algorithms.

A learning model that summarizes data with a set of parameters of fixed size (independent of the number of training examples) is called a parametric model. No matter how much data you throw at a parametric model, it won’t change its mind about how many parameters it needs.

— Artificial Intelligence: A Modern Approach, page 737

The algorithms involve two steps:

- Select a form for the function.
- Learn the coefficients for the function from the training data.

An easy to understand functional form for the mapping function is a line, as is used in linear regression:

b0 + b1*x1 + b2*x2 = 0

Where b0, b1 and b2 are the coefficients of the line that control the intercept and slope, and x1 and x2 are two input variables.

Assuming the functional form of a line greatly simplifies the learning process. Now, all we need to do is estimate the coefficients of the line equation and we have a predictive model for the problem.

Often the assumed functional form is a linear combination of the input variables and as such parametric machine learning algorithms are often also called “*linear machine learning algorithms*“.

The problem is, the actual unknown underlying function may not be a linear function like a line. It could be almost a line and require some minor transformation of the input data to work right. Or it could be nothing like a line in which case the assumption is wrong and the approach will produce poor results.

Some more examples of parametric machine learning algorithms include:

- Logistic Regression
- Linear Discriminant Analysis
- Perceptron
- Naive Bayes
- Simple Neural Networks

Benefits of Parametric Machine Learning Algorithms:

**Simpler**: These methods are easier to understand and interpret results.**Speed**: Parametric models are very fast to learn from data.**Less Data**: They do not require as much training data and can work well even if the fit to the data is not perfect.

Limitations of Parametric Machine Learning Algorithms:

**Constrained**: By choosing a functional form these methods are highly constrained to the specified form.**Limited Complexity**: The methods are more suited to simpler problems.**Poor Fit**: In practice the methods are unlikely to match the underlying mapping function.

## Nonparametric Machine Learning Algorithms

Algorithms that do not make strong assumptions about the form of the mapping function are called nonparametric machine learning algorithms. By not making assumptions, they are free to learn any functional form from the training data.

Nonparametric methods are good when you have a lot of data and no prior knowledge, and when you don’t want to worry too much about choosing just the right features.

— Artificial Intelligence: A Modern Approach, page 757

Nonparametric methods seek to best fit the training data in constructing the mapping function, whilst maintaining some ability to generalize to unseen data. As such, they are able to fit a large number of functional forms.

An easy to understand nonparametric model is the k-nearest neighbors algorithm that makes predictions based on the k most similar training patterns for a new data instance. The method does not assume anything about the form of the mapping function other than patterns that are close are likely have a similar output variable.

Some more examples of popular nonparametric machine learning algorithms are:

- k-Nearest Neighbors
- Decision Trees like CART and C4.5
- Support Vector Machines

Benefits of Nonparametric Machine Learning Algorithms:

**Flexibility**: Capable of fitting a large number of functional forms.**Power**: No assumptions (or weak assumptions) about the underlying function.**Performance**: Can result in higher performance models for prediction.

Limitations of Nonparametric Machine Learning Algorithms:

**More data**: Require a lot more training data to estimate the mapping function.**Slower**: A lot slower to train as they often have far more parameters to train.**Overfitting**: More of a risk to overfit the training data and it is harder to explain why specific predictions are made.

## Further Reading

This section lists some resources if you are looking to learn more about the difference between parametric and non-parametric machine learning algorithms.

### Books

- An Introduction to Statistical Learning: with Applications in R, chapter 2
- Artificial Intelligence: A Modern Approach, chapter 18

### Posts

- What are the advantages of using non-parametric methods in machine learning? on Quora
- What are the disadvantages of non-parametric methods in machine learning? on Quora
- Nonparametric statistics on Wikipedia
- Parametric statistics on Wikipedia
- Parametric vs. Nonparametric on Stack Exchange

## Summary

In this post you have discovered the difference between parametric and nonparametric machine learning algorithms.

You learned that parametric methods make large assumptions about the mapping of the input variables to the output variable and in turn are faster to train, require less data but may not be as powerful.

You also learned that nonparametric methods make few or no assumptions about the target function and in turn require a lot more data, are slower to train and have a higher model complexity but can result in more powerful models.

If you have any questions about parametric or nonparametric machine learning algorithms or this post, leave a comment and I will do my best to answer them.

**Update**: I originally had some algorithms listed under the wrong sections like neural nets and naive bayes, which made things confusing. All fixed now.

## Frustrated With Machine Learning Math?

#### See How Algorithms Work in Minutes

...with just arithmetic and simple examples

Discover how in my new Ebook: Master Machine Learning Algorithms

It covers **explanations** and **examples** of **10 top algorithms**, including:*Linear Regression*, *k-Nearest Neighbors*, *Support Vector Machines* and much more...

#### Finally, Pull Back the Curtain on

Machine Learning Algorithms

Skip the Academics. Just Results.

hi jason

thanks for taking your time to summarize these topics so that even a novice like me can understand. love your posts

i have a problem with this article though, according to the small amount of knowledge i have on parametric/non parametric models, non parametric models are models that need to keep the whole data set around to make future predictions. and it looks like Artificial Intelligence: A Modern Approach, chapter 18 agrees with me on this fact stating neural nets are parametric and once the weights w are learnt we can get rid of the training set. i would say its the same case with trees/naive bays as well.

so what was your thinking behind in categorizing these methods as non-parametric?

thanks,

a confused beginner

Indeed simple multilayer perceptron neural nets are parametric models.

Non-parametric models do not need to keep the whole dataset around, but one example of a non-parametric algorithm is kNN that does keep the whole dataset. Instead, non-parametric models can vary the number of parameters, like the number of nodes in a decision tree or the number of support vectors, etc.

I am also interesting to know why Naive Bayes is categorized as non-parametric.

Yes, Naive bayes is generally a parametric method as we choose a distribution (Gaussian) for the input variables, although there are non-parametric formulations of the method that use a kernel estimator. In fact, these may be more common in practice.

Confused here too.

AFAIK, parametric models have fixed parameter set, i.e. the amount of parameters won’t change once you have designed the model, whereas the amount of parameters of non-parametric models varies, for example, Gaussian Process and matrix factorization for collaborative filtering etc.

Correct me if I’m wrong 🙂

This is correct.

I think the classification does not really depend on what ‘parameters’ are. It’s about the assumption you have made when you try to construct a model or function. Parametric models usually has a probability model (i.e. pdf) behind to support the function-finding process such as normal distribution or other distribution model.

On the other hand, non-parametric model just depends on the error minimisation search process to identify the set of ‘parameters’ which has nothing to do with a pdf.

So, parameters are still there for both parametric and non-parametric ML algo. It just doesn’t have additional layer of assumption to govern the nature of pdf of which the ML algo tries to determine.

Hi Simon, the statistical definition of parametric and non-parametric does not agree with you.

The crux of the definition is whether the number of parameters is fixed or not.

It might be more helpful for us to consider linear and non-linear methods instead…

Is there a relation between parametric/nonparametric models and lazy/eager learning?

In machine learning literature, nonparametric methods are also

call instance-based or memory-based learning algorithms.

-Store the training instances in a lookup table and interpolate

from these for prediction.

-Lazy learning algorithm, as opposed to the eager parametric

methods, which have simple model and a small number

of parameters, and once parameters are learned we no longer

keep the training set.

I have questions of distinguishing between parametric and non parametric algorithms: 1) for linear regression, we can also introducing x^2, x^3 … to make the boundary we learned nonlinear, does it mean that it becomes non parametric in this case?

2) The main difference between them is that SVM puts additional constraints on how do we select the hyperplane . Why perception is considered as parametric while svm is not?

Hi Jianye,

When it comes down to it, parametric means a fixed number of model parameters to define the modeled decision.

Adding more inputs makes the linear regression equation still parametric.

SVM can choose the number of support vectors based on the data and hyperparameter tuning, making it non-parametric.

I hope that is clearer.

Hi Jason,

Nice content here. Had some suggestions,

1. Do you think, it would be a good idea to include histogram: as a simple non-parametric model for estimation probability distribution ? Some beginners might be able to related to histograms.

2. Also, may be mentioning SVM(RBF kernel) as non-parametric to be precise.

What do you think ?

Hi Pramit,

1. nice suggestion.

2. perhaps, there is debate about where SVM sits. I do think it is nonparametric as the number of support vectors is chosen based on the data and the interaction with the argument-defined margin.

Jason, as always, an excellent post.

Thanks Manish.

jason ,it is a good post about parametric and non parametric model

but i still confused

did deep learning supposed to be parametric or non parametric and why

Best Regards

There is not a hard line between parametric and non-parametric.

I think of neural nets as non-parametric myself.

See this:

https://www.quora.com/Are-Neural-Networks-parametric-or-non-parametric-models

Hi

The answer is very convincing, i just have a small question, for pressure distribution plots which ML algorithm should we consider?

Sorry, I don’t know what pressure distribution plots are.

Hi Jason,

Decision tree contains parameters like Splitting Criteria, Minimal Size, Minimal Leaf Size, Minimal Gain, Maximal Depth then why it is called as non-parametric. Please throw some light on it.

They are considered hyperparameters of the model.

The chosen split points are the parameters of the model and their number can vary based on specific data. Thus, the decision tree is a nonparametric algorithm.

Does that make sense?

Could you please briefly tell me what are the parameters and hyperparameters in the following models:

1.Naive Baye

2.KNN

3.Decision Tree

4.Multiple Regression

5.Logistic Regression

Yes, please search the blog for posts on each of these algorithms.