Question

Consider the loss function of linear regression given by J(\theta_0, \theta_1). Given (\theta_0, \theta_1) = 0, 0.5. Estimate \frac{\partial J}{\partial \theta_1} using the data points below:

    \[ \begin{tabular}{|c|c|c|c|c|c|} \hline x & 2 & 4 & 7 & 8 & 10\\ \hline y & 1 & 2 & 2.5 & 3.5 & 5.5\\\hline \end{tabular} \]

Solution

==================================================================================================

We know that (\theta_0, \theta_1) = 0, 0.5 means that y = ax + b \Rightarrow y = 0.5x

    \begin{align*}     \left\frac{\partial J}{\partial \theta_1} = \frac{1}{n} \ \[ \sum_{i=1}^{n} (h_{\theta}(x^{(i)})) - y^{(i)}) \ x_j^{(i)} \] \end{align*}

From the table, we get n=5.

    \begin{align*}     \left\frac{\partial J}{\partial \theta_1} = \frac{1}{5} \ [ [ ((0.5 \ * \ 2) \ - \ 1) * 2 ] + [ ((0.5 \ * \ 4) \ - \ 2) * 4 ] + [ ((0.5 \ * \ 7) \ - \ 2.5) * 7 ] + [ ((0.5 \ * \ 8) \ - \ 3.5) * 8 ] + [ ((0.5 \ * \ 10) \ - \ 5.5) * 10 ] ] \end{align*}

    \begin{align*}     \left = \frac{1}{5} \ [ 0 \ + \ 0 \ + \ 7 \ + \ 4 \ + \ (-5)] = 1.2 \end{align*}

Thus, \frac{\partial J}{\partial \theta_1} = 1.2

Subscribe to Ehan Ghalib!

Invalid email address
We promise not to spam you. You can unsubscribe at any time.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>