## Introduction

Classification and regression are two types of statistical techniques that you can apply to your data in order to make predictions, identify patterns, or group things together. However, they work in very different ways and when it comes to the actual implementation of these techniques, their differences become even more apparent. In this article, we’ll take a look at what the two techniques actually mean and how they differ from each other With examples to help you understand.

## What is Classification?

Classification by definition is a process of categorizing a given set of data into its corresponding classes so that they can be better understood and analyzed.

Let's understand this with an **example** you are given a set of images of different animals and you are required to group them into their corresponding classes i.e. mammals, birds, fish, etc. This is such an easy task for humans to do since we are used to it and have been doing it since we were kids. But what if we have to do the same thing with a machine? Machines are really powerful but they lack the ability to think and understand like humans. So, in order to make a machine classify images of animals into their corresponding groups, we need to first train the machine with some algorithms.

We do this by feeding the machine a large data of images of animals that are labeled and grouped into their corresponding classes already. The machine then looks for patterns in this data and builds a model that can be used to classify new data. This model is then used to predict the class of new data that the machine has not seen before. Like how we can take decisions based on past experience.

If we give the machine a new image of an animal, it will use the model that it has built to predict what class this new image belongs to. In machine learning, this method is known as **supervised learning** because the machine is given a set of training data that is already labeled. So Classification in Machine Learning is a supervised learning technique where the machine is given a set of training data and is required to learn and build a model that can be used to classify a new set of data in the future.

### How classification works in machine learning?

### Types of Classification

**Binary Classification:**In binary classification, the machine is only given two classes to learn from. For example, if we were trying to build a machine that could distinguish between cats and dogs, we would be using binary classification.

**Multi-class Classification:**In multi-class classification, the machine is given more than two classes to learn from. For example, if we were trying to build a machine that could distinguish between different types of animals, we would be using multi-class classification.

**Multi-label Classification**: In multi-label classification, the machine is given a set of data that can belong to multiple classes. For example, if we were trying to build a machine that could distinguish between different types of animals and also identify whether they are friendly or not, we would be using multi-label classification.

## What is Regression?

### How Regression works in Machine Learning?

- Learns the relationship between the size, geography, resources, etc. of a house and its price.
- Makes predictions about the price of a new house based on its size, geography, resources, etc.

### Types of Regression

**Linear Regression**: Linear regression is one of the simplest and most popular types of regression. In this type of regression, the dependent variable is a linear function of the independent variables. It simply finds the best fit line for the given data points and helps to predict the values.

**Polynomial Regression**: Polynomial regression is a type of regression that is used to fit a polynomial function to a dataset.

**Ridge Regression**: Ridge regression is a type of regression that is used to penalize the coefficients of the independent variables.

**Lasso Regression**: Lasso regression is a type of regression that is used to select the most important variables in a dataset.

**Elastic-net Regression**: Elastic-net regression is a type of regression that is used to balance the Ridge and Lasso methods.

## Classification Vs Regression

Regression | Classification |
---|---|

Output variables must be continuous | Output variables must be discrete |

Ordered predicted values | Unordered |

The goal is to predict continuous values based on previous data | The goal is to predict discrete values based on previous data |

Predictions can be done using a best-fit line to predict accurate values | Predictions can be done using a decision boundary which divides the dataset into different classes |

Can evaluate using Mean Squared Error technique | Can evaluate using Accuracy |

Used for weather prediction, house price prediction, cancer prediction, etc. | Used for speech recognition, spam email classification, etc. |