# Coursera: Machine Learning-Andrew NG(Week 3) Quiz - Logistic Regression

These solutions are for reference only.

try to solve on your own

but if you get stuck in between than you can refer these solutions

there are different set of questions ,

we have provided the variations in particular question at the end.

read questions carefully before marking

-----------------------------------------------------------------------------------------

## Logistic Regression

EXPLANATION:

Our estimate for P(y=1|x;Î¸) is 0.7 =>because =>hÎ¸(x) = 0.7

Our estimate for P(y=0|x;Î¸) is 0.3 =>because => P(y=0|x;Î¸) = 1 - P(y = 1| x; Î¸); the former is 1 - 0.7= 0.3

EXPLANATION:

*J(Î¸) will be a convex function, so gradient descent should converge to the global minimum. (true)=>*fact

*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* * (true)*=>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

other statements that can occur in this question:

*At the optimal value of Î¸ (e.g., found by fminunc), we will have J(Î¸) ≥ 0. (true)*

*variation to 3rd question is provided at the end.*

EXPLANATION:

*The cost function J(Î¸) for logistic regression trained with examples is always greater than or equal to zero. (true) *=>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** (true)*=>fact

other statements that can occur in this question:

*The one-vs-all technique allows you to use logistic regression for problems in which each y(i)comes from a fixed, discrete set of values. ***(true)**

**If each y(i) is one of k different values, we can give a label to each y(i)belongs{1,2,....,k} and use one-vs-all as described in the lecture.**

*=>*EXPLANATION:

In this figure, we transition from negative to positive when x1 goes from left of 6 to right of 6 which is true for the given values of Î¸.

$h_{Î¸}(x)=g(Î¸_{0}+Î¸_{1}x_{1}+Î¸_{2}x_{2})$.

$where Î¸_{0}=−6,Î¸_{1}=0,Î¸_{2}=1$.

-----------------------------------------------------------------------------

**variations in 5 th question:**

**variations in 3 th question:**

---------------------------------------------------------------------------------

reference : coursera