To learn more about Lightning: lightning.ai/ Support StatQuest by buying my book The StatQuest Illustrated Guide to Machine Learning or a Study Guide or Merch!!! statquest.org/statquest-store/
@marchanselthomas2 ай бұрын
The explanation is so clean. I was clapping for him from my room. How can someone be so good at their job!
@statquest2 ай бұрын
Thank you! :)
@nuridaw958621 күн бұрын
I clapped too, twice! :)
@jwilliams8210 Жыл бұрын
You are EXCEPTIONALLY good at CLEARLY describing complex topics!!! Thank you!
@statquest Жыл бұрын
Thank you very much! :)
@usamsersultanov689 Жыл бұрын
I think and hope that this video is a preamble for more comlex NLP topics such as Word Embeddings etc.. many thanks for all of your efforts!
@statquest Жыл бұрын
Yes it is! :)
@xanderortega43594 ай бұрын
Cosine Similarity is used as an evaluation tool on word2vec
@mattgenaro9 ай бұрын
Such a simple, yet, a beautiful and powerful concept of similarity. Thanks, StatQuest!
@statquest8 ай бұрын
bam!
@nossonweissman Жыл бұрын
You literally make it so easy!! I can't help but smile 😊😊😊❤️❤️❤️ By far one of my favorite KZbin channels!
@statquest Жыл бұрын
Thank you so much! :)
@insaiyancvk23 күн бұрын
Wonderfully explained, Josh! You've earned a subscriber!
@statquest22 күн бұрын
Thank you!
@jasonlough66404 ай бұрын
Dude these are so good. I have to watch them several times, and then I try write some code to reinforce the concept. Your vides are absolutely amazing.
@statquest4 ай бұрын
Thank you!
@tysontakayushi83943 ай бұрын
I usually hate when people say that a video explains well, because usually this is not the case. But, haha, amazing job! Well done, really nice explained, it's a gamification, they way I understand!
@statquest3 ай бұрын
Thanks!
@virenpai93956 ай бұрын
My Love for learning Data Science and Statistics has increased multi-folds because of you. Thank you Josh!!🙂
@statquest6 ай бұрын
bam! :)
@kforay42 Жыл бұрын
Your videos are such a lifesaver! Could you do one on the difference between PCA and ICA?
@statquest Жыл бұрын
I'll keep that in mind.
@torley Жыл бұрын
QUADRUPLE BAM!!! Thanks for such fun yet pragmatic explainers.
@statquest Жыл бұрын
Thank you!
@dukeduke19104 ай бұрын
This guy is seriously funny. I thought I was the only person who ever watched gymkata (like 50 times, especially the part in the town where everyone was crazy). This video def explains cosine sim clearly. Thk u!
@statquest4 ай бұрын
BAM! :)
@olucasharp Жыл бұрын
It all seems so easy when you speak about such complicated things! Huge talent! And so funny ⚡⚡⚡
@statquest Жыл бұрын
Thank you!
@KarthikNaga329 Жыл бұрын
This is another great video, Josh! question: @3:51 you talk about having 3 Hellos and that still results in a 45 degree angle with Hello World. However, comparing Hello to Hello World seems to be a diff angle from comparing Hello to Hello World World. Is there an intuition as to why this is the case? That is adding as many Hellos to Hello keeps the angle the same, but adding more Worlds to Hello World seems to change the Cosine Similarity.
@statquest Жыл бұрын
Two answers: 1) Just plots the points on a 2-dimensional graph for the two pairs of phrases and you'll see that the angles are different. 2) The key difference is that "hello hello hello" only contains the word "hello". If we had included "world", then the angles would be different. Again, you can plot the points to see the differences.
@bladongarland86353 ай бұрын
Hilarious, easy to understand, and entertaining. Bravo!
@statquest3 ай бұрын
Glad you enjoyed it!
@user-yd8sr9ot9u10 ай бұрын
wow thankyou!!! i don't know how to calculate it , but after watching this, i become mathmatician!!
@statquest10 ай бұрын
bam!
@raphaelbonillo21922 ай бұрын
Você democratiza a matemática! Deveriam fazer assim nas escolas.
@statquest2 ай бұрын
Muito obrigado!
@magicfox94 Жыл бұрын
Excellent explaination! I hope it is the first of a NLP series of videos!
@statquest Жыл бұрын
I hope to do word embeddings soon.
@bjornnorenjobb Жыл бұрын
Awesome video! I had no idea what Cosine Similarity was, but you explained super clearly
@statquest Жыл бұрын
Thanks!
@suzhenkang Жыл бұрын
pretty good .
@AreyHawUstad2 ай бұрын
Holy shit did I land on a gold mine. Love the explanation (minus the intro, sorry Josh). Thanks a bunch!
@statquestАй бұрын
Thanks!
@FreeMc54Ай бұрын
you are insane at explaining clearly, btw you sing really well😂
@statquestАй бұрын
Thanks! 😃
@spambaconeggspamspam Жыл бұрын
Perfect! I'm trying to figure out how to best present my Single Cell Data in a UMAP and saw i cosine is the default distance metric in Seurat!
@statquest Жыл бұрын
BAM! :)
@ibrahimogunbiyi42963 ай бұрын
I came here as I need to learn something in NLP. Thank you, I understood it clearly.
@statquest3 ай бұрын
BAM! :)
@RichardGreco Жыл бұрын
Great video. Very interesting. I hope to see you apply this to more examples.
@statquest Жыл бұрын
We'll see it used in CatBoost for sure.
@abdulrafay24207 ай бұрын
What a great way of explaination !! Love it ❤
@statquest7 ай бұрын
Thanks!
@infraia2 ай бұрын
Excellent explanation!
@statquest2 ай бұрын
Thanks!
@theedspage Жыл бұрын
Hello! Hello! Hello! Thank you for introducing me to this topic! Subscribed.
@statquest Жыл бұрын
Awesome! Thank you!
@Ghulinzer Жыл бұрын
Great video! I've seen though in many articles out there that people consider cosine similarity the same as Pearson's correlation since they produce the same outcome when E(X) = E(Y) = 0 and the means of X and Y = 0. This is not true since both measure different things. Cosine similarly measures the cosine of the angle between two vectors in a multi-dimensional space and returns a similarity score as explained in the video, while Pearson's correlation measure the linear relationship between 2 variables.
@statquest Жыл бұрын
Correct!
@user-yu7ie2em5b12 сағат бұрын
You really are the best !
@RaynerGS10 ай бұрын
I love you!!!! Salute from Brazil.
@statquest10 ай бұрын
Muito obrigado! :)
@davidmurphy563 Жыл бұрын
Could you cover discrete cosine/fourier transforms pretty please?* I've love to know how to break signals up into their component frequencies. If you haven't already!
@statquest Жыл бұрын
I'll keep that in mind.
@Iiochilios1756 Жыл бұрын
Have you seen 3blue1brown video on this topic? Not sure if it about descreet FT.
@exoticcoder5365 Жыл бұрын
I must watch Gymkata ! Thanks for the recommendation ! And excellent explanation of the topic !
@statquest Жыл бұрын
bam! :)
@ericvaish8 күн бұрын
How am I able to understand this topic? Wasn't this supposed to be difficult? 😭 Seriously Great Explanation Josh.
@statquest8 күн бұрын
Thank you!
@user-kp8lw1nz7m5 ай бұрын
you are the King Josh 👏👏👏👏 wonderful job!!!
@statquest5 ай бұрын
Thank you! 😃
@MOROCCANFREEMIND6 ай бұрын
The quality of your explanation is more than triple bam!!😂
@statquest6 ай бұрын
Thanks!
@anuj5576 Жыл бұрын
Super simplistic explanation! Thanks for your effort.
@statquest Жыл бұрын
Thanks!
@willw4096 Жыл бұрын
Great video! My notes: 3:52 4:23
@statquest Жыл бұрын
bam!
@chrisguiney Жыл бұрын
This video also does a good job highlighting how cosine and dot products are the same. Unless I'm mistaken, that equation can be written dot(a, b) / (magnitude(a) * magnitude(b)), where magnitude(x) = sqrt(dot(x, x))
@statquest Жыл бұрын
yep
@suaridebbarma12553 ай бұрын
this video was absolutely a BAM!!
@statquest3 ай бұрын
Thanks!
@DrKnowsMore9 күн бұрын
Like most things, it is relatively straightforward when you remove the jargon
@statquest9 күн бұрын
bam! :)
@azzahamed20637 ай бұрын
This is an AMAZING explanation !!
@statquest7 ай бұрын
Thank you!
@limebro8833 Жыл бұрын
This video saved me, I cannot thank you enough.
@statquest Жыл бұрын
Bam! :)
@AU-hs6zw Жыл бұрын
You deliver the moment I need it. Thanks
@statquest Жыл бұрын
BAM! :)
@abrahammahanaim3859 Жыл бұрын
Hey josh thanks for the video nice explanation.
@statquest Жыл бұрын
You bet!
@muhammadazeemmohsin56668 ай бұрын
what's an amazing explanation. Thanks for the video.
@statquest8 ай бұрын
Thanks!
@AmineBELALIA Жыл бұрын
this video needs more views it is awesome
@statquest Жыл бұрын
Thank you! :)
@fazelamirvahedi99119 ай бұрын
Thank you for making all of these informative, simple and precise videos. I wondered what happens if two phrases deliver the same meaning but have different orders of words, for instance: A) I like Gymkata. B) I really like Gymkata. In this case doesn't the extra adverb "really" in the second sentence disturb the phrase matrix? And one more question, if the three phrases have the same length and two of them have the same meaning but have used different words, like: A) I like Gymkata. B) I love Gymkata. C) I like volleyball. In this case, would the cosine similarity between A and B be more than A and C?
@statquest9 ай бұрын
In this video, we're simply counting the number of words that are the same in different phrases, however, you can use other metrics to calculate the cosine similarity, and that is often the case. For example, we could calculate "word embeddings" for each word in each phrase and calculate the cosine similarity using the word embedding values and that would allow phrases with similar meanings to have larger similarities. To learn more about word embeddings, see: kzbin.info/www/bejne/rJq9o4Kkf8ifj5I
@bachdx2812 Жыл бұрын
thanks a lot. this kind of videos are super helpful for me !!!
@statquest Жыл бұрын
Thanks! :)
@lifeisbeautifu15 ай бұрын
Thank you!
@statquest5 ай бұрын
Thanks!
@millennialm1money5004 ай бұрын
Great video 🎉
@statquest4 ай бұрын
Thank you 😁!
@sciab36745 ай бұрын
thanks a lot. easy to understand
@statquest5 ай бұрын
Thanks!
@chris-graham Жыл бұрын
"in contrast, this last sentence is from someone who does not like troll 2" - I was expecting a BOOOO after that lol
@statquest Жыл бұрын
Ha! That would have been great.
@jonathanramos66905 ай бұрын
Amazing!!
@statquest5 ай бұрын
Thanks!
@debatradas1597 Жыл бұрын
Thank you so much
@statquest Жыл бұрын
You're most welcome!
@murilopalomosebilla2999 Жыл бұрын
Hello!! Nice video!
@statquest Жыл бұрын
Thank you!
@kavita8925 Жыл бұрын
Your Explanation is great
@statquest Жыл бұрын
Thanks!
@edmiltonpeixeira3221 Жыл бұрын
Parabéns pelo conteúdo. Excelente explicação, como não encontrei em nenhum outro vídeo
@statquest Жыл бұрын
Muito obrigado! :)
@ymperformance Жыл бұрын
Great video and great explanation! Thanks.
@statquest Жыл бұрын
Glad it was helpful!
@gsp_admirador Жыл бұрын
nice easy explanation
@statquest Жыл бұрын
Thanks!
@banibratamanna54464 ай бұрын
the generalized equation of cosine similarity comes from the dot product of 2 vectors in multidimension.....by the way big fan of yours❤
@statquest4 ай бұрын
scaled to be between -1 and 1. :)
@pouryajafarzadeh5610 Жыл бұрын
Cosine similarity is a good method for comparing the embedding vectors, especially for face recognition.
@statquest Жыл бұрын
Nice!
@dataanalyticswithmichael8931 Жыл бұрын
superb ! Thank you for the explanation
@statquest Жыл бұрын
Thanks!
@madhubabukencha5037 Жыл бұрын
Man you are not human, you are my god 😀
@statquest Жыл бұрын
:)
@mystmuffin3600 Жыл бұрын
Cool! (in StatQuest voice)
@statquest Жыл бұрын
bam! :)
@samrasoli Жыл бұрын
useful, thanks
@statquest Жыл бұрын
Thanks!
@smegala3815 Жыл бұрын
Very useful 👍
@statquest Жыл бұрын
Thank you! :)
@miltonborges73568 ай бұрын
Amazing
@statquest8 ай бұрын
Thanks!
@CristianoGarcia10 Жыл бұрын
Excellent and clear video! I wonder why NLP applications use more often cosine distance rather than other metrics, such as euclidean distance. Is there a clear reason for that? Thanks in advance
@statquest Жыл бұрын
I'm not certain, but one factor might be how easy it is to compute (people often omit the denominator making the calculation even easier) and it might be nice that the cosine similarity is always between 0 and 1 and doesn't need to be normalized.
@cartulinito Жыл бұрын
Great video as we are used to.
@statquest Жыл бұрын
Thank you! :)
@Levy957 Жыл бұрын
you are amazing
@statquest Жыл бұрын
Thanks!
@Francescoct Жыл бұрын
Great video! Have you made one for the Word Embeddings?
@statquest Жыл бұрын
Coming soon!
@Shehab-Codes9 ай бұрын
Thank you so much I had no idea what cosine similarity is and you illustrated it easily, appreciate it Btw how cosine similarity can result in -ve number
@statquest9 ай бұрын
The cosine similarity can be calculated for any 2 sets of numbers, and that can result in a negative value.
@luizcarlosazevedo9558 Жыл бұрын
Hey, great video as always!! Is the cosine similarity good for regression problems in which the targets are pretty close to zero? Im trying to implement some accuracy metrics for a transformer model
@statquest Жыл бұрын
Hmm... I bet it would work (if you had a row of predictions and a row of known values).
@AxDhan Жыл бұрын
I'm a native spanish speaker, and it surprised me when it started speaking spanish, it will reach more people, but they will miss your motivating silly songs xD
@statquest Жыл бұрын
Thanks! Yeah - I'm not sure what to do about the silly songs. :)
@lonok844 ай бұрын
Wow, I used this to make a bot from whatsapp, to put client on flow/menu based on the first message from client
@statquest4 ай бұрын
bam!
@yuan8947 Жыл бұрын
Always thank you for the great and easy-understanding video! And I have a question about the totally different word. If there are 2 sentences like very good/super nice, since very, good, super, nice are totally different, the cosine similarity will be 1. However, they are actually the same meaning! I want to ask what else preprocessing should we do toward such situation? Thank you so much!
@statquest Жыл бұрын
I think you might need more context (longer phrases) to get a better cosine similarity. I just used 2 words because I could draw them, but in practice, you use more.
@itSinger7 ай бұрын
tysm
@statquest7 ай бұрын
Thanks!
@XEQUTE5 ай бұрын
You're kinda like Phil from Mordern Family but for Data Science/ Statistics
@statquest4 ай бұрын
:)
@cheesus859413 күн бұрын
Great explanation but I can’t believe how pissed I got when u kept repeating hello!!!!! And world!!! Omg
@statquest13 күн бұрын
noted
@cheesus859413 күн бұрын
@@statquest thanks statquest🙏
@s0meus3r5 ай бұрын
I got it BAMM !!🎉
@statquest5 ай бұрын
BAM!
@MrJ17J Жыл бұрын
Super interesting ! Do you have examples of how those are implemented in practice ?
@statquest Жыл бұрын
I talk about that at the start of the video, but it's also used by CatBoost to compare the predicted values for a bunch of samples to their actual values.
@SystemDesign-proАй бұрын
if you say DOUBLE BAM one more time, I'm goona FLMAO
@statquestАй бұрын
:)
@aquagardening58037 ай бұрын
BAM!!!
@statquest7 ай бұрын
:)
@nidhi_singh94945 ай бұрын
Hey...so cosine is only depends on angle not on lengths... When the case of three Hello were shown, how it can be distinguished between them as similarity is same for both sentence
@statquest5 ай бұрын
What time point, minutes and seconds, are you asking about?
@fathan3306Ай бұрын
BAMMM!
@statquestАй бұрын
:)
@jainanshu2000 Жыл бұрын
Great video ! One question - how is this diffrent from the regular string comparison we use various programming languages?
@statquest Жыл бұрын
I'm not sure I understand your question. My understanding of string comparison in programming languages is that it just compares the bits to make sure they are equal and the result is a boolean True/False type thing.
@001kebede11 ай бұрын
how can we relate this with correlation between two continuous random variables?
"Troll 2" should be considered 1 word. It refers to only one idea, the troll sequel movie which is different than the first troll movie.
@statquest Жыл бұрын
Sounds good to me!
@arvindmathur555620 күн бұрын
Somewhere it says Cosine Similarity is a number between -1 and +1 but in other places it is said to be between 0 & 1. What is the truth?
@statquest20 күн бұрын
The cosine similarity can be between -1 and 1. If all the input data are positive (like they are in a bunch of the examples in this video, since we are just using count data, and count data is positive) then you'll be restricted to values between 0 and 1, but the data don't always have to be positive.
@Mrnafuturo Жыл бұрын
Does cosine similarity equation ends up being a vector normalization of the projection of one vector over the other one?
@statquest Жыл бұрын
I believe that is correct.
@ZOBAER496 Жыл бұрын
Can you please tell about some applications of cosine similarity like where is it used in which type of problems?
@statquest Жыл бұрын
I talk about that at the start of the video, but you can also use it whenever you want to compare two rows of data. For example, CatBoost uses it compare predicted values for a bunch of data to their actual values.
@sushi666 Жыл бұрын
Can you please do Spherical K Means with Cosine Similarity as the distance metric?
@statquest Жыл бұрын
I'll keep that in mind.
@hansu7474 Жыл бұрын
What is the applications of cosine similarity?
@statquest Жыл бұрын
Umm... Did you watch the video? It's the first thing I talk about.
@rajashreechakraborty7477 ай бұрын
Can u please help me with this? This is my data: A: cosine: 0.58, z-score: 372 B: cosine: 0.63 , z-score: 370 How can I find the p-value/significance of the 0.5 change in the cosine similarities?
@statquest7 ай бұрын
We didn't cover p-values in the video.
@PromitiDasgupta-mz7uc Жыл бұрын
can i use cosine similarity for building a similarity matrix between two different brain regions?
@statquest Жыл бұрын
Probably.
@Olddays100s10 ай бұрын
but if the phrases are Hello World and World Hello. The cosine would still be 1. how to differentiate between them using cosine similarities? do algorithms introduce another dimension?
@statquest10 ай бұрын
Algorithms use other methods to keep track of word order. For example, transformers use positional encoding. To learn more, see: kzbin.info/www/bejne/sKm0qoeBbdaor7s
@eddiesec Жыл бұрын
I still don't understand how that works for embeddings though. Each embedding dimension should represent loosely a grammatical property of the words, than how can one word that is farther than another in a single dimension (as in your Hello Hello Hello example) be considered identical?
@statquest Жыл бұрын
I'll do a video on embeddings soon.
@c.nbhaskar4718 Жыл бұрын
what is the formula if we have more than 2 sentences ??
@statquest Жыл бұрын
I believe you just calculate it for all combinations of the sentences.