Machine Learning with Python: Linear Regression
Linear regression is the most basic and commonly used type of predictive analysis. It is used for finding a linear relationship between target and one or more predictors.
There are two types of Linear Regression: Simple and Multiple.
Simple Linear Regression
Simple linear regression is useful for finding relationship between two continuous variables. One is the target variable and one is the dependent variable.
A linear regression is a linear line on the graph with the equation
$y_{pred} = b_{0} + b_{1}x$
The model selects the values of b_{0} and b_{1} such that the error is minimum.
$Error = \sum_{i=1}^n(y_{actual} - y_{pred})^2$
Let's see an example in python.
Suppose we want to predict the price of a house based on it's area.
The python code is as follows:
It is similar to simple linear regression but with multiple variables.
Let us see the previous example of house price prediction, but with more attributes.
Multiple Linear regression
Multivariate or multiple linear regression is the most commonly used type of linear regression. Generally, a single attribute is not enough to predict the future values.It is similar to simple linear regression but with multiple variables.
Let us see the previous example of house price prediction, but with more attributes.
Gajjab
ReplyDelete