COSC 3430 · Artificial Intelligence

Cosine Similarity, in Two Dimensions

Drag the blue point (or use a preset) and watch the angle change. The query — “I want an action movie” — stays fixed at [1, 0]. Same formula the movie-recommender assignment uses, just in 2D so the angle can actually be seen.
cosine similarity —
angle θ —
q · m (dot product) —
‖m‖ (movie vector length) —
cos(θ) = (q · m) / (‖q‖ ‖m‖)

Drag past the axes to see negative coordinates too — cosine similarity can go negative once a vector points the opposite direction, even though that can't happen with plain 0/1 genre features like the ones in the movie-recommender assignment. Keyboard: focus the point (tab to it), then use arrow keys to nudge it — hold shift for bigger steps.

Built to accompany COSC 3430 (Artificial Intelligence). Everything here computes live in the browser from the actual formula — nothing is a canned animation.