Machine Learning Questions and Answers – Linear Regression – Cost Function

This set of Machine Learning Multiple Choice Questions & Answers (MCQs) focuses on “Linear Regression – Cost Function”.

1. The hypothesis is given by h(x) = t0 + t1x. What are t0 and t1?
a) Value of h(x) when x is 0, intercept along y-axis
b) Value of h(x) when x is 0, the rate at which h(x) changes with respect to x
c) The rate at which h(x) changes with respect to x, intercept along the y-axis
d) Intercept along the y-axis, the rate at which h(x) changes with respect to x
View Answer

Answer: d
Explanation: Since t1 is the coefficient of x, it is the rate at which h(x) changes with respect to x. t0 is the intercept at the y-axis, but practically, it may not be the value of h(x) when x=0.

2. The hypothesis is given by h(x) = t0 + t1x. t0 gives the value of h(x) when x is 0.
a) True
b) False
View Answer

Answer: b
Explanation: Although t0 is the intercept along the y-axis, it is not always the value of h(x) when x is 0. For e.g. a learner predicts a hypothesis which gives the price of a house based on its size. The hypothesis may have a y-intercept but that does not mean it is equal to the price of the house whose size is 0. A non-existent house cannot have a price.

3. The hypothesis is given by h(x) = t0 + t1x. What is the goal of t0 and t1?
a) Give negative h(x)
b) Give h(x) as close to 0 as possible, without themselves being 0
c) Give h(x) as close to y, in training data, as possible
d) Give h(x) closer to x than y
View Answer

Answer: c
Explanation: t0 and t1 try to minimize prediction error on the training set. Since y is the target variable, h(x) must be y (ideally) or closer to y. This is what t0 and t1 try to achieve.
advertisement
advertisement

4. The hypothesis is given by h(x) = t0 + t1x. What does t1 = 0 after several iterations imply?
a) The target variable is independent of x
b) Hypothesis is wrong
c) t0 is 0
d) x is the target variable
View Answer

Answer: a
Explanation: The equation t1 = 0 implies that h(x) does not change with change in x. The value of h(x) is not dependent on x. Thus, the target variable is not dependent on x.

5. In a linear regression problem, h(x) is the predicted value of the target variable, y is the actual value of the target variable, m is the number of training examples. What do we try to minimize?
a) (h(x) – y) / m
b) (h(x) – y)2 / 2*m
c) (h(x) – y) / 2*m
d) (y – h(x))
View Answer

Answer: b
Explanation: The objective is to find the difference between the predicted value and actual value of the target variable and to minimize this error. If we get a negative value, then no minimizing can be done, that’s why squaring is done. To get an average over the dataset, the squared value is divided by twice the number of training examples.

6. The cost function contains a summation expression.
a) True
b) False
View Answer

Answer: c
Explanation: The objective of the cost function is to minimize the error. Thus it calculates the error for each example and sums it. The error for each example is basically the difference between the predicted value and the actual value of the target variable.

7. What is the simplified hypothesis?
a) h(x) = t1x
b) h(x) = t0 + t1x
c) h(x) = t0
d) h(x) = t0x
View Answer

Answer: a
Explanation: In the simplified hypothesis, we assume that t0 = 0. It is safe to assume this because often it is practical that the value of h(x) is 0 when the value of x is 0, especially in problems where we try to output the cost price o something.
advertisement

8. The simplified hypothesis reduces the complexity of the cost function.
a) True
b) False
View Answer

Answer: a
Explanation: When we ignore the intercept term in the hypothesis equation, we are only left with the x term. Thus the cost function only tries to minimize the term t1 which is the coefficient of x. This simplifies the calculation of the cost function to a certain degree.

9. In the simplified hypothesis, what does hypothesis H and cost function J depend on?
a) Both are functions of x
b) J is a function of x, H is a function of t1
c) H is a function of x, J is a function of t1
d) Both are functions of t1
View Answer

Answer: c
Explanation: The simplified hypothesis: h(x) = t1x; thus h is only dependent on the value of x, as t1 is kept constant for a single iteration through the dataset. Now, after the completion of one iteration through the dataset, the cost function calculates the error and alters t1 in order to minimize the error.
advertisement

10. (x(1), y(1)) = 1, 1.5, (x(2), y(2)) = 2, 3, (x(3), y(3)) = 3, 4.5. Hypothesis: h(x) = t1x, where t1 = 1.5. How much error is obtained?
a) 4.5
b) 0
c) 22.5
d) 1.5
View Answer

Answer: b
Explanation: Cost function: J(t1) = [(t1x(1) – y(1))2 + (t1x(2) – y(2))2 + (t1x(3) – y(3))2] / 2*m
= [0 + 0 + 0] / 2*3
= 0/6
= 0.

11. (x(1), y(1)) = 1, 1.5, (x(2), y(2)) = 2, 3, (x(3), y(3)) = 3, 4.5. Hypothesis: h(x) = t1x, where t1 = 2. How much error is obtained?
a) 0.3
b) 0
c) 0.42
d) 0.5
View Answer

Answer: c
Explanation: Cost function: J(t1) = [(t1x(1) – y(1))2 + (t1x(2) – y(2))2 + (t1x(3) – y(3))2] / 2*m
= [0.52 + 12 + 1.52] / 2*3
= 2.5/6
= 0.42.

12. How to graphically find t1 for which cost function is minimized?
a) Plot J(t1) against t1 and find minima
b) Plot t1 against J(t1) and find minima
c) Plot J(t1) against t1 and find maxima
d) Plot t1 against J(t1) and find maxima
View Answer

Answer: a
Explanation: At the minima of the graph obtained by plotting J(t1) against t1, we have the minimal value of J(t1) for the given dataset, using linear regression. This is the desired cost function. So, we take this value of t1 and use it in the final hypothesis.

13. What is the ideal value of t1?
a) 0
b) Depends on the dataset
c) 1
d) 0.5
View Answer

Answer: b
Explanation: There is no way that t1 can be determined before observing the dataset. It can take any value based on the rate of change of the target variable with the change of the independent variable. It can even take a negative value if the target variable is indirectly proportional to the independent variable.

14. Hypothesis is: h(x) = t0 + t1x. How do we graphically find the desired cost function?
a) Plot J(t0, t1) against t0 and find minima
b) Plot J(t0, t1)) against t1 and find minima
c) Plot J(t0, t1) against either t1 or t0 and find minima
d) Make a 3-d plot with J(t0, t1) against t1 and t0 and find minima
View Answer

Answer: d
Explanation: J(t0, t1) is dependent on both the parameters, t1 and t0. Thus we need to find the J(t0, t1) as a function of both t1 and t0. So we need to plot in 3 dimensions.

Sanfoundry Global Education & Learning Series – Machine Learning.

To practice all areas of Machine Learning, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.