...

/

Supervised Learning: Regression

Supervised Learning: Regression

Learn the fundamental principles behind regression and implement regression using the sklearn library.

Supervised learning

Supervised learning is a type of ML where we use the data with labeled outputs. For example, say we want to forecast the ambient temperature. We collect salient features such as the amount of rainfall, duration of sunshine, and average wind speed. We also record the temperature against each data point as continuous labels. We use temperature along with the input features to train an ML model, which predicts the ambient temperature for new (test) data. When we use continuous labels in our ML model, we deal with the regression problem.

The counterpart of regression is the classification problem that uses discrete output labels. Human action recognition and spam email detection are examples of classification problems in which we have a small set of classes or discrete labels to predict.

In this lesson, we discuss regression.

What is regression?

In a regression problem, the output labels have a continuous range of values, e.g., temperature prediction. Contrarily, in a classification problem, e.g., face recognition, the output labels are discrete values.

If we assume a linear relationship between the input features and the output target variables, we have the linear regression problem. Here, we discuss linear regression.

Note: Regression involves the predictions of continuous-valued quantities, such as weather and stock market predictions.

A linear regression model determines a linear relationship between one or more independent input features and a continuous target variable that’s dependent on the input features. Univariate or simple linear regression uses only one feature, whereas multiple linear regression uses multiple input features.

This figure shows univariate data having feature xx and continuous output value yy. Linear regression aims to find a line that passes through data points such that the error between the line and data points is as small as possible.

Formula for linear regression

We know that the equation of a line involves the slope of the line and the intercept on the y-axis. Linear regression can be modeled using the equation of a line if we have only one feature vector, x1x_1.

Here,  θ0\theta_0 and  θ1 ...