-
Notifications
You must be signed in to change notification settings - Fork 881
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
Add intercept to x arrays in solution to part d) of problem 3 of Problem Set 1 #8
Conversation
…ed to input features x for training and validation set.
Add intercept to x arrays in solution to part d) of problem 3 of Problem Set 1
…sv set as test set, instead of the proper ds5_test.csv set. Corrected this by replacing line test_x, test_y = util.load_csv('data/ds5_train.csv') with line test_x, test_y = util.load_csv('data/ds5_test.csv')
One more bug fix. I have corrected this by replacing line |
Agree with your |
Here is my understanding. Feel free to ask further clarifications. Whenever we use the notation \theta^T x, it means that we are using the "x_0=1" convention, i.e., we are adding the intercept to x. If we don't apply this convention, \theta would have n+1 elements (\theta_0,\theta_1,...,\theta_n) while x would have n elements (x_1,x_2,...,x_n), so the notation \theta^T x would not make sense. In the notes for Generalised Linear Model and in the problem set source code, we use the notation \theta^T x, so we should add the intercept to x. If we don't use it, your solution to the problem set still runs but the quantity \theta^T x is then be given by Another observation that convinces me about the need for the intercept comes by comparing the section of the notes on Linear Regression (in which we use the hypothesis h(x)=\theta^T x with the convention x_0=1) with the section "Ordinary least squares" in the part about Generalised Linear Models. In the latter, the notes show that we get the same hypothesis h(x)=\theta^T x, so we must be still using the convention x_0=1. In conclusion, in the discussion about Generalised Linear Models of the notes and the problem set, we are still using the intercept term. |
I see, makes sense. Thanks for explaining. From the notebook, it also looks like a typo in the problem statement: Could you please update the problem statement code as well: And I'd also add a comment like |
…Problem Set 1: the intercept should be added when loading the training dataset.
Thanks! I'm happy with both fixes. One last question: what was the change in |
Thank you for reviewing and for your making this repo available. I changed that notebook in the commit 26936f5 above. The commit message says what I changed: Fixed bug: the function train_perceptron used to load the ds5_train.csv set as test set, instead of the proper ds5_test.csv set. |
Thanks, I looked into that commit and still was confused about the notebook. Maybe just revert it? Happy to merge all other changes. |
I see that there are a bunch of other changes in the metadata of the notebook. I don't really know how they were created, but I think it happened because I ran the notebook on a different machine. I will revert the commit and make a new commit that only replaces the line |
….ipynb made in commit 26936f5
The previous commit only reverted the old commit, but did not replace the line |
Take the file
problem-sets-solutions/PS1/code/src/p03d_poisson.py
. This contains the solution to part d) of problem 3 of Problem Set 1.An intercept should be added when the training set and validation set are loaded. To do so, I replaced the line
x_train, y_train = util.load_dataset(train_path, add_intercept=False)
with
x_train, y_train = util.load_dataset(train_path, add_intercept=True)
and replaced the line
x_eval, y_eval = util.load_dataset(eval_path, add_intercept=False)
with
x_eval, y_eval = util.load_dataset(eval_path, add_intercept=True)