MinMaxScaling of target in Content Based Recommender

Hi,

In the Content-based recommenders practice lab, the target rating y_train is scaled using MinMaxScaler of feature range(-1, 1).

Why is it needed to perform this operation on target? I understand that we are normalizing the input feature vectors using the l2 norm and the target range is between 0 and 5. Hence scaling is needed for target values. But why it has to be between (-1, 1 ) and not (0, 1) which is the usual range of MinMaxScaler?

Hello @bhavanamalla,

I have written down how feaures and vu and vm are normalized according to the lab’s text.

So, to fairly estimate the similarity of two vectors (vu, vm), we need to L2-normalize them before dotting them, but the dotted result must be between -1 and 1, so we need our target label to be in that range too, and the lab chose to make it between 0 and 1.

Cheers,
Raymond

Thank you @rmwkwok for your time

Just also adding a little bit of mathematical intuition that might be useful for someone in the future.

L2 norm of vector x = ||x|| = sqrt(x1^2 + x2^2 + … + xn^2)

L2 normalizing a vector = dividing each element / L2 norm

The resulting vector will have normalized values.

This resulting vector will have a magnitude of length 1 (i.e. unit length). If we perform sqrt(sum(values^2)), then it will be equal to 1.

This vector is also sometimes called unit norm or unit vector because its l2 norm which is sqrt(sum(values^2)) is 1

The dot product/inner product of 2 vectors u, v can be

              u . v= |u| * |v| * cos(θ)

(or)

Also, dot product = sum(elementwise multiplication)

When the vectors u and v are L2 normalized, the magnitude of those vectors |u| and |v| will have unit length.

Hence, the dot product simplifies to:

                                u · v = cos(θ)

Here θ is the angle between the 2 vectors in the Euclidean space

The range of cos(θ) lies between [-1, 1].

So, when we perform the dot product of l2_normalized vectors, then the resulting result ranges between [-1, 1]

Best Regards

3 Likes