Multiple Linear Regression
Multiple Linear Regression Equation

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:

y=b+m1x1+m2x2y = b + m_{1}x_{1} + m_{2}x_{2}

Equation 6.2 The equation for multiple linear regression that uses three independent variables is this:

y=b+m1x1+m2x2+m3x3y = b + m_{1}x_{1} + m_{2}x_{2} + m_{3}x_{3}

Equation 6.3 As a result, since multiple linear regression can use any number of independent variables, its general equation becomes:

y=b+m1x1+m2x2+...+mnxny = b + m_{1}x_{1} + m_{2}x_{2} + ... + m_{n}x_{n}

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.

Remember, with sklearn‘s LinearRegression() method, we can get these values with ease.

The .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 .coef_.

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 .coef_.

Folder Icon

Sign up to start coding

Already have an account?