CSCE 470 Lecture 6

From Notes
Jump to navigation Jump to search

« previous | Friday, September 6, 2013 | next »


Search Ranking

Two Key Questions

  1. How to represent each query or document?
    • set of terms
    • bag of words → TF, log TF, TF IDF
  2. How to measure similarity (or distance) between q and d?
    • Jaccard
    • Manhattan Distance (|u1−v1|+…+|un−vn|
    • Euclidean Distance ((u1−v1)2+…+(un−vn)2)
    • Cosine

Cosine Similarity

Measures angle between query vector q→ and document vector d→. Two vectors are similar if

  • the angle between is smaller (i.e. θ→0), and thus
  • the cosine similarity is larger (i.e. cos⁡θ→1)

From vector calculus, we can find the cosine between two vectors as follows:

sim(q→,d→)=cos⁡θ=q→⋅d→‖q→‖‖d→‖

If the vectors are stored in a normalized format, the similarity formula becomes much easier:

q^=q→‖q→‖d^=d→‖d→‖sim(q^,d^)=cos⁡θ=q^⋅d^