Jump to content

Talk:Cosine similarity

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Cleanup

[edit]

The article needed to be removed from the Jaccard Index page, that made no sense. However, new sources are needed for this page now. I tagged it as an article lacking sources
I did that a while ago but forgot to sign. Just placed it within the scope of Mathematics and Computer Science WikiProjectsBob0513 (talk) 04:16, 7 January 2009 (UTC)[reply]

Angle or cos(angle) ?

[edit]

I always thought cosine similarity was a number between -1 and 1, i.e. the cosine of the angle. However, this article describes the angle itself as the similarity. I'm going to change it, but someone can change it back if they know otherwise, with citation. dfrankow (talk) 21:43, 13 October 2008 (UTC)[reply]

angle or cos(angle) - changing again

[edit]

I believe both versions exist and are both named "cosine similarity", however they have important different properties. I will change the article reflect this.

extended to Tanimoto distance

[edit]

this is both meaningless and incorrect; so-called Tanimoto (falsely named but commonly used, I've already changed that article!) derives from Jaccard not from Cosine; I will change this to a link to a related metric

RichardThePict (talk) 08:58, 4 November 2011 (UTC)[reply]

I agree; the section 'Confusion with "Tanimoto" coefficient' that boils down to a message to the reader "please don't confuse cosine similarity with Tanimoto coefficient" is completely unnecessary, especially since Tanimoto coefficient doesn't look anything like cosine similarity. That's like adding a section to Al Pacino biography warning the reader not to confuse him with Robert De Niro.

Mishapom (talk) 17:55, 27 June 2019 (UTC)[reply]

@RichardThePict: @Mishapom: I removed this section Owoo6pha (talk) 19:24, 10 August 2020 (UTC)[reply]

second formula in Angular similarity section

[edit]

Why does this

second variant of angular similarity exist? It is written that it supposed to be used "in a domain where the vector coefficients [elements, I think] are always positive". But if vector elements are positive then similarity (formula in Definition section) is always positive too (already ranged in [0,1]), so we don't need to use this transformation at all. Am I right? I think the second formula in Angular similarity section should be deleted and only first formula should be used when vector elements may be both positive and negative. — Preceding unsigned comment added by 94.178.78.245 (talk) 17:24, 1 February 2014 (UTC)[reply]

no, the point here is to bound the outcome into [0,1] - if all the vector elements (usually these are coefficients!) are positive, then the cosine is in [0,1] so the arccos is in [0,pi]; if the cosine is in [-1,1] then the arrcos is in [0,2.pi], hence the different scaling of the distance. Working in similarity rather a lot, I can assure you these bounds are useful! RichardThePict (talk) 10:36, 26 March 2014 (UTC)[reply]

Ochiai coefficient

[edit]

who has put this in here, and why? It's (almost) completely unrelated! If nobody answers, I'm gong to remove it in a while RichardThePict (talk) 10:39, 26 March 2014 (UTC)[reply]

No, Ochiai coefficient is cosine similarity188.123.252.192 (talk) 12:25, 20 June 2018 (UTC).[reply]

No difference from correlation coefficient, no need for separate article on less common terms

[edit]

This is the geometric interpretation of correlation (r). These alternate and much less common terms should be merged into that article where these other terms can be covered very briefly. 73.149.246.232 (talk) 22:34, 16 May 2020 (UTC)[reply]

Incorrect statement marked by me as "dubious"

[edit]

Hello guys, someone wrote the following wrong statement about cosine similarity: "It is thus a judgment of orientation and not magnitude: " This is incorrect. The cosine similarity is the MAGNITUDE of the projection of the first unit vector onto the second unit vector. And another point: I understand that the person wanted to stress onto the importance of direction, but note that the similarity is not measured by the angle, but by the "cosine" function of the angle --- the output is a scalar quantity. Thus, the cosine as a function is a "projection" operation, whereas the output of the cosine function is the MAGNITUDE of the resulting projection.

To the person who wrote the dubious text: consider the following example - if one wants to have a measure only of the direction (without considering projections), then it is possible to define a normalized angle , where . In this case, it could be said that what is measured is "the direction in some loose sense", but such loose usage would be very close to confusing "angle" with "direction" (so I cannot recommend it). Please edit and correct the main text. Danko Georgiev (talk) 07:41, 9 October 2021 (UTC)[reply]

I have now corrected the dubious statement. The lack of dependence of the inner product of two unit vectors on the "magnitude" of the two vectors is because their lengths are fixed to be "unit". General inner product of non-unit vectors will depend on the vector magnitude, but this will not be related with cosine similarity.Danko Georgiev (talk) 07:19, 10 October 2021 (UTC)[reply]
I want to add that unskilled authors often write factually incorrect sentences. For example, "Paris is not a city" is false, whereas "Paris is not a city in Germany" is true! Apparently, the same language mistake was done by the author who claimed that the "cosine similarity is not a judgement of magnitude", while he/she had in mind that "cosine similarity is not a judgement of the magnitudes of the two non-zero vectors for which this measure is defined". Taking into consideration all of the above, I have now added the following sentence in the main text: "From the latter definition, it follows that the cosine similarity depends only on the angle between the two non-zero vectors, but not on their magnitudes.". Danko Georgiev (talk) 08:06, 10 October 2021 (UTC)[reply]

Angular distance and similarity are NOT cosine similarity

[edit]

Angular distance and similarity are NOT cosine similarity, and I do not see that it is relevant to the article to explicitly mention that some people possibly have used incorrect definition of "cosine similarity". By the way, the claim that such people exist and have used incorrect definition of "cosine similarity" is not sourced and needs at least several citations to reputable journal articles in order to confirm the claim. Without citations, the bulk of the section seems to me to be original research containing irrelevant personal opinions that should be removed. Danko Georgiev (talk) 08:18, 11 October 2021 (UTC)[reply]

I have moved text on "cosine distance" just before the section on "Angular distance and similarity". Then I have introduced consistent notation between the two consecutive sections, for similarity and for distance. Material lacking reliable source was cleaned up. Danko Georgiev (talk) 08:18, 17 October 2021 (UTC)[reply]

poor python code

[edit]

The code just added is very poor. The lists are both needed, and the claim that you should add a small constant to avoid division by zero will cause wrong results if the vectors are short. Do we really want Wikipedia to be a collection of our code samples? In my opinion it does not add to the article. 93.135.3.208 (talk) 01:41, 11 February 2023 (UTC)[reply]

I agree that it does not add to the article, and I have removed it. If there are editors out there who want to see code, let's first discuss here what that would look like. —Quantling (talk | contribs) 14:24, 11 February 2023 (UTC)[reply]
Well, evidently there are editors out there who want to see code, else the edit wouldn't have been made.
For many, math becomes more understandable when represented alongside its code equivalent. Furthermore, what exactly would a high quality python code example look like? It was intended to be intuitive for anyone to understand, even those new to the python language. Lastly, the need to add a small value can be excluded from the content, but at what cost? To anyone reading the code it might not be apparent without otherwise mentioned that a division by zero error can occur. So, either this is made explicitly clear to the reader, or some in-code error handling for such circumstances are included.
In my opinion, it does add to the article and should exist as it increases accessibility plus makes the article more relevant to the types of individuals visiting it - namely, those who may be looking to implement cosine similarity programmatically. As for the best form in which to write the code that makes it both intuitive, understandable and concise, I'll let you decide. SaltyBeans (talk) 09:46, 13 February 2023 (UTC)[reply]
Please, read the relevant guidelines of Wikipedia, namely MOS:ALGO and MOS:MATH#Algorithms. In summary, they state that, in Wikipedia, pseudocode is preferred to specific popular languages, even a popular one, such as Python. D.Lazard (talk) 10:47, 13 February 2023 (UTC)[reply]
Also, having had a look on the article, it appears that the only reason for adding code in this article, is that the § Definition is poorly written and much too technical for the intended audience. In fact, the concept of cosine similarity is used only in data processing and statistics, and people working in these areas are generally not mathematicians. So, vectors, dot product, norm, ... must not be supposed to be known by readers. This means that the definition must be first presented on tuples of numbers, and must be preceded by the definition of the dot product and the norm for tuples. If this section is correctly rewritten, no code will be needed, since this article is not a place for teaching basic programming. D.Lazard (talk) 11:13, 13 February 2023 (UTC)[reply]
I apologize for the sloppiness of my original posting here. Yes, @SaltyBeans: you exist and you are working towards making Wikipedia better, so I thank you! I meant something along the lines that, unless you were already convinced that we should skip the code, then let's get a discussion going. I meant encouragement, ... but failed badly.
I second much of what @D.Lazard: just wrote. —Quantling (talk | contribs) 21:10, 13 February 2023 (UTC)[reply]

L2

[edit]

In section L2-normalized Euclidean distance, why is "2" in subscript and not in superscript?

--Mortense (talk) 18:21, 9 August 2023 (UTC)[reply]