# Feature scaling and mean normalization

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.

• 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? – Dougal Jun 20 '15 at 19:32

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$

• @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) – jeff Sep 19 '15 at 0:50
• Isn't s supposed to be maximum possible value-minimum possible value rather than actual maximum value-actual minimum value? – shiva Jan 20 '17 at 12:38
• 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 – Ashok Felix Apr 19 '18 at 2:04
• yup, rounding off the answer to 2 decimal places = -0.47 – Edwin Ikechukwu May 10 '18 at 0:21

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

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.

• It is not informative to just give the right answer. You should explain it or derive it. – Michael Chernick Dec 15 '17 at 6:06
• @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 – Hải Mai Đức Dec 15 '17 at 6:17
• This is Cross Validation and not Stackoverflow. – Michael Chernick Dec 15 '17 at 6:31
• @MichaelChernick sorry, my fault :D – Hải Mai Đức Dec 16 '17 at 9:06