Home Multiple Linear Regression
Post
Cancel

Multiple Linear Regression

What is Multiple Linear Regression?

Multiple linear regression is used to estimate the relationship between two or more independent variables(X) and one dependent variable (Y):

  • X is regarded as the predictor, explanatory, or independent variable.
  • Y is regarded as the response, outcome, or dependent variable. As a result, the formula for multiple linear regression is expressed as the formula below.
$ y = b_{0} + b_{1} \times x_{1} + b_{2} \times x_{2}+ \ldots + b_{n} \times x_{n} $

You can use multiple linear regression when you want to know:

  • How strong the relationship is between two or more independent variables and one dependent variable (e.g., how rainfall, temperature, and amount of fertilizer added affect crop growth).
  • The value of the dependent variable at a certain value of the independent variables (e.g., the expected yield of a crop at certain levels of rainfall, temperature, and fertilizer addition).

Example


Code



1
2
3
from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(X_train, y_train)



Expected values



1
2
3
4
5
6
7
8
9
10
[[103015.2]
 [132582.28]
 [132447.74]
 [ 71976.1]
 [178537.48]
 [116161.24]
 [ 67851.69]
 [ 98791.73]
 [113969.44]
 [167921.07]]



Predicted values



1
2
3
4
5
6
7
8
9
10
[[103282.38]
 [144259.4 ]
 [146121.95]
 [77798.83]
 [191050.39]
 [105008.31]
 [81229.06]
 [97483.56]
 [110352.25]
 [166187.94]]





Implementation

This post is licensed under CC BY 4.0 by the author.