Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save HabibMrad/d0d8b35a7ae67df85215d79a0378161a to your computer and use it in GitHub Desktop.
Save HabibMrad/d0d8b35a7ae67df85215d79a0378161a to your computer and use it in GitHub Desktop.
Machine Learning (Stanford) Coursera Logistic Regression Quiz (Week 3, Quiz 1) for the github repo: https://github.com/mGalarnyk/datasciencecoursera/tree/master/Stanford_Machine_Learning

Machine Learning Week 3 Quiz 1 (Logistic Regression) Stanford Coursera

Github repo for the Course: Stanford Machine Learning (Coursera)
Quiz Needs to be viewed here at the repo (because the image solutions cant be viewed as part of a gist)

Question 1

Answer Explanation
Our estimate for P(y=0|x;θ) is 0.8. P(y=0|x;θ) = 1 - P(y = 1| x; θ); the former is 1 - 0.2 = 0.8
Our estimate for P(y=1|x;θ) is 0.2. hθ(x) = 0.2

Question 2

Answer Explanation
J(θ) will be a convex function, so gradient descent should converge to the global minimum. none
Adding polynomial features (e.g., instead using hθ(x) = g(θ0 + θ1x1 + θ2x2 + θ3x2 + θ4x1x2 + θ5x2 )) could increase how well we can fit the training data Adding new features can only improve the fit on the training set: since setting θ3 = θ4 = θ5 = 0 makes the hypothesis the same as the original one, gradient descent will use those features (by making the corresponding non-zero) only if doing so improves the training set fit

Question 3

Question 4

Answer Explanation
The cost function J(θ) for logistic regression trained with examples is always greater than or equal to zero. The cost for any example x(i) is always ≥ 0 since it is the negative log of a quantity less than one. The cost function J(θ) is a summation over the cost for each eample, so the cost function itself must be greater than or equal to zero.
The sigmoid function is never greater than one none

Question 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment