Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linear regression bias clarification #54

Closed
joelgenter opened this issue Jan 25, 2019 · 3 comments
Closed

Linear regression bias clarification #54

joelgenter opened this issue Jan 25, 2019 · 3 comments

Comments

@joelgenter
Copy link
Contributor

I just want to clarify my understanding before making any clarifying changes. In the Linear Regression article under 'Bias Term', it reads:

Below we add a constant 1 to our features matrix. By setting this value to 1, it turns our bias term into a constant.

bias = np.ones(shape=(len(features),1))
features = np.append(bias, features, axis=1)

So the purpose of adding the 1 along with the other features in each example is so that the 1 will be multiplied by the 'bias weight' when the dot product of the features and weights is performed in the predict() function. Is that accurate?

@joelgenter joelgenter changed the title Linear Regression Bias Clarification Linear regression bias clarification Jan 25, 2019
@bfortuner
Copy link
Owner

I think the bias is added not multiplied, right?

@ivanistheone
Copy link
Contributor

So the purpose of adding the 1 along with the other features in each example is so that the 1 will be multiplied by the 'bias weight' when the dot product of the features and weights is performed in the predict() function. Is that accurate?

Yes, exactly. We "augement" the data with a column of constant 1 so that can treeat the whole expressions using dot product rather than handle bias manually. Here is an example shows its equivalent:

screen shot 2019-02-14 at 8 33 04 am

@joelgenter
Copy link
Contributor Author

Awesome. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants