Now that we have implemented Multiple Linear Regression, we will learn how to tune and evaluate the model. Before we do that, however, it’s essential to learn the equation behind it.
Equation 6.1 The equation for multiple linear regression that uses two independent variables is this:
Equation 6.2 The equation for multiple linear regression that uses three independent variables is this:
Equation 6.3 As a result, since multiple linear regression can use any number of independent variables, its general equation becomes:
Here, m1, m2, m3, … mn refer to the coefficients, and b refers to the intercept that you want to find. You can plug these values back into the equation to compute the predicted y values.
LinearRegression() method, we can get these values with ease.
.fit() method gives the model two variables that are useful to us:
.coef_, which contains the coefficients
.intercept_, which contains the intercept
After performing multiple linear regression, you can print the coefficients using
Coefficients are most helpful in determining which independent variable carries more weight. For example, a coefficient of -1.345 will impact the rent more than a coefficient of 0.238, with the former impacting prices negatively and latter positively.
Print out the coefficients using