# Bag of Words

## What is bag of Words useful for?

Bag of words is currently a state of the art Method of measuring the similarity between 2 Texts

## How Does it work?

Given 2 Texts, the occurence of each word in both texts is counted. When in the same words occurred in two texts multiple times, **bag of words** will tell us that they are simmilar to each other&#x20;

&#x20;

![Example of Document Dimension 3 , where only Words lion, dog and cat Occur](https://3768672318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA0hKIwdUDH-_SetCq8%2F-LC0gmRcOLB7Z2qrycxt%2F-LC0hI3shNEbDMlzIg3f%2Fimage.png?alt=media\&token=f9954f73-11d6-4b05-96d2-46c08c21a72d)

&#x20;

* Given **X Documents** with **N** **different words,** the bag of Words algorithm projects them into an **N** dimensional Space (Hyperplane) .&#x20;



* In This Hyperplane, every Document is just a point. Now we can measure similarities between individual points with regular linear algebra aka **euklidean distance** .&#x20;
