# ▸ Linear Regression with One Variable :

Recommended Machine Learning Courses:

1. Consider the problem of predicting how well a student does in her second year of college/university, given how well she did in her first year. Specifically, let x be equal to the number of “A” grades (including A-. A and A+ grades) that a student receives in their first year of college (freshmen year). We would like to predict the value of y, which we define as the number of “A” grades they get in their second year (sophomore year).
Here each row is one training example. Recall that in linear regression, our hypothesis is $\inline&space;h\theta(x)&space;=&space;\theta_0&space;+&space;\theta_1x$ to denote the number of training examples.

For the training set given above (note that this training set may also be referenced in other questions in this quiz), what is the value of $\inline&space;m$? In the box below, please enter your answer (which should be a number between 0 and 10).
4 

1. Many substances that can burn (such as gasoline and alcohol) have a chemical structure based on carbon atoms; for this reason they are called hydrocarbons. A chemist wants to understand how the number of carbon atoms in a molecule affects how much energy is released when that molecule combusts (meaning that it is burned). The chemist obtains the dataset below. In the column on the right, “kJ/mol” is the unit measuring the amount of energy released.

You would like to use linear regression ($\inline&space;h_\theta(x)&space;=&space;\theta_0&space;+&space;\theta_1x$) to estimate the amount of energy released (y) as a function of the number of carbon atoms (x). Which of the following do you think will be the values you obtain for $\inline&space;\theta_0$ and $\inline&space;\theta_1$ ? You should be able to select the right answer without actually implementing linear regression.

1. For this question, assume that we are using the training set from Q1.
Recall our definition of the cost function was $\inline&space;J(\theta_0,&space;\theta_1&space;)&space;=&space;\frac{1}{2m}&space;\sum_{i=1}^{m}&space;(h&space;(x^{(i)}&space;)&space;-&space;y^{(i)})^2$

What is $\inline&space;J(0,1)$? In the box below,

0.5

1. Suppose we set $\inline&space;\theta_0&space;=&space;0,&space;\theta_1&space;=&space;1.5$ in the linear regression hypothesis from Q1. What is $\inline&space;h_\theta(2)$ ?
3

1. Suppose we set $\inline&space;\theta_0$ = −2, $\inline&space;\theta_1$ = 0.5 in the linear regression hypothesis from Q1. What is $\inline&space;h_\theta(6)$?
1

1. Let $\inline&space;f$ be some function so that $\inline&space;f(\theta_0&space;,&space;\theta_1&space;)$ outputs a number. For this problem, $\inline&space;f$ is some arbitrary/unknown smooth function (not necessarily the cost function of linear regression, so $\inline&space;f$ may have local optima).
Suppose we use gradient descent to try to minimize $\inline&space;f(\theta_0&space;,&space;\theta_1&space;)$ as a function of $\inline&space;\theta_0$ and $\inline&space;\theta_1$.
Which of the following statements are true? (Check all that apply.)

1. In the given figure, the cost function $\inline&space;J(\theta_0,&space;\theta_1)$ has been plotted against $\inline&space;\theta_0$ and $\inline&space;\theta_1$, as shown in ‘Plot 2’. The contour plot for the same cost function is given in ‘Plot 1’. Based on the figure, choose the correct options (check all that apply).

### Check-out our free tutorials on IOT (Internet of Things):

1. Suppose that for some linear regression problem (say, predicting housing prices as in the lecture), we have some training set, and for our training set we managed to find some $\inline&space;\theta_0,&space;\theta_1$, such that $\inline&space;J(\theta_0&space;,&space;\theta_1)&space;=&space;0$.
Which of the statements below must then be true? (Check all that apply.)

&
Click here to see more codes for Raspberry Pi 3 and similar Family.
&
Click here to see more codes for NodeMCU ESP8266 and similar Family.
&
Click here to see more codes for Arduino Mega (ATMega 2560) and similar Family.

Feel free to ask doubts in the comment section. I will try my best to answer it.
If you find this helpful by any mean like, comment and share the post.
This is the simplest way to encourage me to keep doing such work.

Thanks & Regards,
- APDaga DumpBox

Let fff be some function so that

f(Î¸0,Î¸1)f(\theta_0, \theta_1)f(Î¸0​,Î¸1​) outputs a number. For this problem,

fff is some arbitrary/unknown smooth function (not necessarily the

cost function of linear regression, so fff may have local optima).

Suppose we use gradient descent to try to minimize f(Î¸0,Î¸1)f(\theta_0, \theta_1)f(Î¸0​,Î¸1​)

as a function of Î¸0\theta_0Î¸0​ and Î¸1\theta_1Î¸1​. Which of the

following statements are true? (Check all that apply.)

If theta_zero and theta_one are initialized so that theta_zero = theta_one, then by symmetry (because we do simultaneous updates to two parameters), after one iteration of the gradient descent, we will still have theta_zero = theta_one

(please give the answer whether above statement is correct (i think its wrong) but with an explanation if possible! thanks!

1. This statement is wrong.
If we initialize \theta_0 & \theta_1 to same value. After a simultaneous update it is not necessary that \theta_0 & \theta_1 will be updated to same value. (That updated value of \theta_0 & \theta_1 will depend on the slope of the curve along x_1 & x_2 respectively)

On other hand, for Neural Networks, Above statement hold true. There we have to break the symmetry. That's why we initialize all the weights randomly. But no need to do it in Gradient descent.

Thanks

2. How you solved second problem plz tell me

1. which 2nd problem?
I have provided solutions to all the problems for all weeks.

2. dear akshay can you provide the matlab solution of the chemist problem, where we have m=12

3. Thanks for the solutions but can you help with some details on how you came up with these answers.
Videos are coursera are not that straight forward or some links that we can go through. Appreciate your help.

1. Honestly, I think you can get most of the answers through Coursera theory lectures only. If you have doubt for any particular question. You can ask here as well.
I have also provided reasons for the selected answers for some of the quizzes.

1. Sorry to know that. I tried to add as many question as possible.

5. Please tell me how to solve question 2 (Many substances that can burn (such as gasoline and alcohol) have a chemical structure based on carbon atoms...) ?

1. This is the example of curve fitting. Put the value of theta1 & theta2 and (some values of x) in the equation given in the question and check for which values of thetas your answer is loosely matching with last column of the table.

Values of thetas for which output of equation and last column are matching, we can say that particular curve is fitting better. and that's the answers.

NOTE: value of (y) from equation and table won't matching exactly. search for nearby values.

6. Suppose we set \theta_0 = −1, \theta_1 = 0.5 in the linear regression hypothesis from Q1. What is h_\theta(4)?

1. h_theta(x) = theta_0 + theta_1 * x
h_theta(4) = -1 + 0.5(4) = -1 + 0.5(4) = -1 + 2 = 3

7. thanks for sharing brother, but can you upload a the paper piece on which u have solved these questions

8. Hi,
How did you get the answer for question 2? Isn't m=4?
Thanks!

1. The one with J(0,1)

2. Just put the all the values in the cost function equation and calculate it.
you have all the values like theta0, theta1, m, x, y, etc

9. Thank You for existing.