1

I am new to machine learning and I am confused with what is the function of linear regression intercept parameter is doing.

When setting the parameter, fit_intercept=False, I get the .coef_ value as 287.986236, however, when setting fit_intercept=True, I get the .coef_ value as 225.81285046.

Why is there a difference? And I am not sure how to interpret the results and compare these values!

    lm = LinearRegression(fit_intercept=False).fit(REStaten_[['GROSS_SQUARE_FEET']], REStaten_['SALE_PRICE'])
    lm.coef_
    # 287.986236

    lm = LinearRegression(fit_intercept=True).fit(REStaten_[['GROSS_SQUARE_FEET']], REStaten_['SALE_PRICE'])
    lm.coef_
    # 225.81285046
desertnaut
  • 57,590
  • 26
  • 140
  • 166
raja
  • 11
  • 3
  • look [this] (https://stackoverflow.com/questions/46779605/in-the-linearregression-method-in-sklearn-what-exactly-is-the-fit-intercept-par) – Akash Kumar Sep 28 '19 at 20:06
  • 1
    Possible duplicate of [In the LinearRegression method in sklearn, what exactly is the fit\_intercept parameter doing?](https://stackoverflow.com/questions/46779605/in-the-linearregression-method-in-sklearn-what-exactly-is-the-fit-intercept-par) – desertnaut Sep 28 '19 at 21:50

1 Answers1

0
  • The Slope and Intercept are the very important concept of Linear regression.
  • The slope indicates the steepness of a line and the intercept indicates the location where it intersects an axis.
  • If we set the Intercept as False then, no intercept will be used in calculations (e.g. data is expected to be already centered).

When we are using LR model in a dataset, It is trying to plot the "Line of best fit" by increasing or decreasing the Slope and Intercept values. You are getting different .coef_ values because you are disabling the Intercept parameter in your first attempt and enabling it on your second attempt.

Hope this helps. For more info, you can refer the scikit-learn documentation. Sk Learn Linear regression

Community
  • 1
  • 1
Pranab
  • 11
  • 1
  • 3