12
$\begingroup$

I'm taking Andrew Ng's machine learning course and was unable to get the answer to this question correct after several attempts. Kindly help solve this, though I've passed through the level.

Suppose $m=4$ students have taken some class, and the class had a midterm exam and a final exam. You have collected a dataset of their scores on the two exams, which is as follows:

midterm (midterm)^2   final
89        7921        96
72        5184        74
94        8836        87
69        4761        78

You'd like to use polynomial regression to predict a student's final exam score from their midterm exam score. Concretely, suppose you want to fit a model of the form $h_\theta(x) = \theta_0 + \theta_1 x_1 + \theta_2 x_2$, where $x_1$ is the midterm score and $x_2$ is (midterm score)^2. Further, you plan to use both feature scaling (dividing by the "max-min", or range, of a feature) and mean normalization.

What is the normalized feature $x_2^{(4)}$? (Hint: midterm = 89, final = 96 is training example 1.) Please enter your answer in the text box below. If applicable, please provide at least two digits after the decimal place.

$\endgroup$
  • 3
    $\begingroup$ Hi Oduwole! For this kind of question, we ask that you please read the self-study tag info (and edit your post to add the tag). In particular, what approaches have you tried so far, and what do you not understand? $\endgroup$ – Dougal Jun 20 '15 at 19:32
12
$\begingroup$
  1. $x^{(4)}_2 \to 4761$.

  2. Nomalized feature $\to \dfrac{x - u}{s}$ where $u$ is average of $X$ and $s = max - min = 8836 - 4761 = 4075$.

  3. Finally, $\dfrac{4761 - 6675.5}{4075} = -0.47$

$\endgroup$
  • 3
    $\begingroup$ @oduwoleoluwasegun just a reminder, the question itself changes everytime you take the quiz. For me, it was asking ${x_1}^{(2)}$ for example. So be careful about the question and compute the answer using this solution. This is how I got it correct. Also, don't forget to round upto 2 decimal digits (or whatever the question is asking) $\endgroup$ – jeff Sep 19 '15 at 0:50
  • $\begingroup$ Isn't s supposed to be maximum possible value-minimum possible value rather than actual maximum value-actual minimum value? $\endgroup$ – shiva Jan 20 '17 at 12:38
  • $\begingroup$ The mistake I did was not to round off the value. Octave formula - (4761-mean(A))/range(A) returned ans = -0.46982. Rounded value would have been -0.47, but I entered -0.46 $\endgroup$ – Ashok Felix Apr 19 '18 at 2:04
  • $\begingroup$ yup, rounding off the answer to 2 decimal places = -0.47 $\endgroup$ – Edwin Ikechukwu May 10 '18 at 0:21
0
$\begingroup$

Since , normalized $x = \frac{x - u}{s}$

where

  • u = mean of the feature x,
  • s = $range(max - min)$ or standard deviation

Here, in this quiz s means the range actually so, normalized x = $\frac{4761 - 6675.5}{8836 - 4761}$ = -0.47

$\endgroup$
0
$\begingroup$

Read the guide please : They said : Please round off your answer to two decimal places and enter in the text box below. The answer is -0.37 . I did it and success.

$\endgroup$
  • $\begingroup$ It is not informative to just give the right answer. You should explain it or derive it. $\endgroup$ – Michael Chernick Dec 15 '17 at 6:06
  • $\begingroup$ @Biranchi : ohm sorry because this is the fisrt time I have commented on stackoverflow. My answer: Average = (7921 + 5184 + 8836 + 4761)/4 = 6675.5 Range = 8836 - 4761 = 4075 x2 = (5184 - 6675.5)/4075 = -0.366 And in cousera quiz, they said : Please round off your answer to two decimal places and enter in the text box below so you need to round the result with two decimal => We have -0.37 $\endgroup$ – Hải Mai Đức Dec 15 '17 at 6:17
  • $\begingroup$ This is Cross Validation and not Stackoverflow. $\endgroup$ – Michael Chernick Dec 15 '17 at 6:31
  • $\begingroup$ @MichaelChernick sorry, my fault :D $\endgroup$ – Hải Mai Đức Dec 16 '17 at 9:06
0
$\begingroup$

enter image description here

My answer:

Average = (7921 + 5184 + 8836 + 4761)/4 = 6675.5

Range = 8836 - 4761 = 4075

x2 = (5184 - 6675.5)/4075 = -0.366 = -0.37 (rounded to 2 decimal places)

Edited: I got the error. I should have rounded to 2 decimal places.

$\endgroup$
  • 1
    $\begingroup$ This is not an Answer. The error to your problem is you're not rounding off to two decimal places (like the question asks). Therefore -0.37 is the correct answer. $\endgroup$ – Drew Szurko Jan 2 '18 at 20:49
  • 1
    $\begingroup$ you missed rouding the result to 2 decimal places i.e -0.37 $\endgroup$ – Edwin Ikechukwu May 10 '18 at 0:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.