I know what you’re thinking: this doesn’t take magnitude into account. In the image above, the left-most angle has a cosine value close to 1, the middle a value around 0, and the right-most a value nearing -1. Vectors that run in completely opposite directions of each other (a 180-degree angle) have a value of -1 and vectors that run in the same exact direction (a 0-degree angle) have a value of 1. The image below gives you a sense of what different angles mean in terms of similarity.Ĭosine values range from -1 to 1. Thus, the smaller the angle, the more similar the vectors. A smaller angle results in a larger cosine value. Cosine similarityĬosine similarity is simply a measure of the angle between two vectors. columns in a DataFrame) could be considered a group of data points with 107-dimensional vectors.īut why all this talk of vectors? Well, it’s important for a pillar of content-based recommendation systems: cosine similarity. This may sound more complicated than it actually is - any dataset that happens to have 107 numerical features (i.e. So I ended up with 107-dimensional “poem vectors”. Lexical richness (unique words divided by total words).Word complexity (average number of syllables per word).End rhyme ratio (number of end rhymes to number of lines).Sentiment, subjectivity score (a measure of…subjectivity).Sentiment, polarity score (a measure of positivity, negativity, or neutrality).Length of line (average number of words per line).For PO-REC, the seven features I used were: Refer to my previous article for some nitty gritty details about the project. For my project I used seven features I engineered based on the structure and form of poems, as well as 100-dimensional document vectors created using a Doc2Vec model. Basically all you’ll need is a DataFrame with all numerical values and without any NaN values. The preparationįirst, you’ll need to get your data in good order. Move over GoodReads! There’s a disruptor in town, known as PO-REC, your friendly neighborhood poem-recommending robot.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |