1
$\begingroup$

I'm new to Data Science. I'm trying to understand cosine similarity and it seems like the equation is about finding the distance between two vectors. From what I've Googled, a vector needs to have magnitude and direction. But in CS, it seems like it's a 1-dimensional array. Is vector in CS the same as vector in Physics? If so, what is the direction of a vector. And if a vector is like this [1, 0, 1, 0] what is the magnitude of this vector?

$\endgroup$
1

2 Answers 2

3
$\begingroup$

As you ask specifically for the Cosine Similarity technique, it has magnitude and direction, and similar to a vector which is used in Physics, as Cosine Similarity deals with vectors in an inner product space.

enter image description here

So, the magnitude of vectors is exactly the same as the formula in Physics (summating over the squares of the vector elements.)

$\endgroup$
1
$\begingroup$

Yes, they are the same.

The array [1, 0, 1, 0] represents a vector in $4$ dimensional euclidean space ($\mathbb{R}^4$) with tails at [0, 0 , 0 ,0] and head at [1, 0, 1, 0]. So your vector is "pointing" in the direction of your given set of coordinates.

This might be easier to visualize in $2$ dimensions: for example, the array [1,0] corresponds to the unit vector along the $x$-axis centered at the origin.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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