Term Frequency–Inverse Document Frequency

Slides:



Advertisements
Similar presentations
Lecture 6: Scoring, Term Weighting and the Vector Space Model
Advertisements

Introduction to Information Retrieval Introduction to Information Retrieval Lecture 7: Scoring and results assembly.
TEXT SIMILARITY David Kauchak CS159 Spring Quiz #2  Out of 30 points  High:  Ave: 23  Will drop lowest quiz  I do not grade based on.
Text Similarity David Kauchak CS457 Fall 2011.
| 1 › Gertjan van Noord2014 Zoekmachines Lecture 4.
Hinrich Schütze and Christina Lioma
Introduction to Information Retrieval (Manning, Raghavan, Schutze) Chapter 6 Scoring term weighting and the vector space model.
TF-IDF David Kauchak cs160 Fall 2009 adapted from:
CpSc 881: Information Retrieval
Indexing The essential step in searching. Review a bit We have seen so far – Crawling In the abstract and as implemented Your own code and Nutch If you.
Ch 4: Information Retrieval and Text Mining
CS276 Information Retrieval and Web Mining
Hinrich Schütze and Christina Lioma
Information Retrieval IR 6. Recap of the last lecture Parametric and field searches Zones in documents Scoring documents: zone weighting Index support.
The Vector Space Model …and applications in Information Retrieval.
Vector Space Model : TF - IDF
CES 514 Data Mining March 11, 2010 Lecture 5: scoring, term weighting, vector space model (Ch 6)
CS276A Text Information Retrieval, Mining, and Exploitation Lecture 4 15 Oct 2002.
Documents as vectors Each doc j can be viewed as a vector of tf.idf values, one component for each term So we have a vector space terms are axes docs live.
Web search basics (Recap) The Web Web crawler Indexer Search User Indexes Query Engine 1 Ad indexes.
Boolean and Vector Space Models
1 Vector Space Model Rong Jin. 2 Basic Issues in A Retrieval Model How to represent text objects What similarity function should be used? How to refine.
Automated Essay Grading Resources: Introduction to Information Retrieval, Manning, Raghavan, Schutze (Chapter 06 and 18) Automated Essay Scoring with e-rater.
Document ranking Paolo Ferragina Dipartimento di Informatica Università di Pisa.
Scoring, Term Weighting, and Vector Space Model Lecture 7: Scoring, Term Weighting and the Vector Space Model Web Search and Mining 1.
Web search basics (Recap) The Web Web crawler Indexer Search User Indexes Query Engine 1.
Information Retrieval continued Many slides in this presentation are from Christopher D. Manning, Prabhakar Raghavan and Hinrich Schütze, Introduction.
TF-IDF David Kauchak cs458 Fall 2012 adapted from:
Information Retrieval Lecture 2 Introduction to Information Retrieval (Manning et al. 2007) Chapter 6 & 7 For the MSc Computer Science Programme Dell Zhang.
Basic ranking Models Boolean and Vector Space Models.
Advanced topics in Computer Science Jiaheng Lu Department of Computer Science Renmin University of China
Information Retrieval and Data Mining (AT71. 07) Comp. Sc. and Inf
Weighting and Matching against Indices. Zipf’s Law In any corpus, such as the AIT, we can count how often each word occurs in the corpus as a whole =
Term Frequency. Term frequency Two factors: – A term that appears just once in a document is probably not as significant as a term that appears a number.
Information Retrieval and Web Search IR models: Vectorial Model Instructor: Rada Mihalcea Class web page: [Note: Some.
Ranking in Information Retrieval Systems Prepared by: Mariam John CSE /23/2006.
Web search basics (Recap) The Web Web crawler Indexer Search User Indexes Query Engine 1.
Introduction to Information Retrieval Introduction to Information Retrieval COMP4210: Information Retrieval and Search Engines Lecture 5: Scoring, Term.
Vector Space Models.
Introduction to Information Retrieval CSE 538 MRS BOOK – CHAPTER VI SCORING, TERM WEIGHTING AND THE VECTOR SPACE MODEL 1.
CIS 530 Lecture 2 From frequency to meaning: vector space models of semantics.
Lecture 6: Scoring, Term Weighting and the Vector Space Model
Information Retrieval Techniques MS(CS) Lecture 7 AIR UNIVERSITY MULTAN CAMPUS Most of the slides adapted from IIR book.
Information Retrieval and Web Search IR models: Vector Space Model Instructor: Rada Mihalcea [Note: Some slides in this set were adapted from an IR course.
Introduction to Information Retrieval Introduction to Information Retrieval Lecture 9: Scoring, Term Weighting and the Vector Space Model.
Web Information Retrieval
Information Retrieval and Web Search IR models: Vector Space Model Term Weighting Approaches Instructor: Rada Mihalcea.
Introduction to Information Retrieval Introduction to Information Retrieval CS276: Information Retrieval and Web Search Pandu Nayak and Prabhakar Raghavan.
IR 6 Scoring, term weighting and the vector space model.
Introduction to Information Retrieval Information Retrieval and Data Mining (AT71.07) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor:
The Vector Space Models (VSM)
Plan for Today’s Lecture(s)
7CCSMWAL Algorithmic Issues in the WWW
Ch 6 Term Weighting and Vector Space Model
chapter 1 I N F O R M A T I O N R E T R I E V A L & VISUALIZATION
Prof. Paolo Ferragina, Algoritmi per "Information Retrieval"
Information Retrieval and Web Search
Prof. Paolo Ferragina, Algoritmi per "Information Retrieval"
Information Retrieval and Data Mining (AT71. 07) Comp. Sc. and Inf
אחזור מידע, מנועי חיפוש וספריות
Information Retrieval and Web Search
Basic Information Retrieval
Representation of documents and queries
From frequency to meaning: vector space models of semantics
CS 430: Information Discovery
Boolean and Vector Space Retrieval Models
CS276: Information Retrieval and Web Search
VECTOR SPACE MODEL Its Applications and implementations
Presentation transcript:

Term Frequency–Inverse Document Frequency

Key issues We want to search a collection of document (corpus). How important a word is to a document in a collection or corpus How to represent documents as vectors in a vector space

Term-document binary incidence matrix Sec. 6.2 Term-document binary incidence matrix Each document is represented by a binary vector ∈ {0,1}|V|

Term-document count matrix Sec. 6.2 Term-document count matrix Each document is a count vector in ℕv According to this, “Caesar” is more important than “Brutus”. However Caesar was killed in Act 3, scene 1.

Term frequency tf The term frequency tft,d of term t in document d is defined as the number of times that t occurs in d. Raw term frequency is not what we want. A document with 10 occurrences of the term is more relevant than a document with 1 occurrence of the term. But not 10 times more relevant. Relevance does not increase proportionally with term frequency. Need to dampen (soften) the effect of this proportion.

Log-frequency weighting Sec. 6.2 Log-frequency weighting The log frequency weight of term t in d is 0 → 0, 1 → 1, 2 → 1.3, 10 → 2, 1000 → 4, etc.

Rare terms in a collection Sec. 6.2.1 Rare terms in a collection Rare terms are more informative than common terms Consider a term in the query that is rare in the collection (e.g., arachnocentric) Documents containing this term are very likely to be relevant to the query arachnocentric We want a high weight for rare terms like arachnocentric. Even though document frequency is low but the term is importance

Inverse Document Frequency Sec. 6.2.1 Inverse Document Frequency dft is the document frequency of t: the number of documents that contain t dft  N, the number of documents We define the idf (inverse document frequency) of t by We use log (N/dft) instead of N/dft to dampen the effect of idf. What happens if the term appears in all the documents?

Sec. 6.2.2 tf-idf weighting The tf-idf weight of a term is the product of its tf weight and its idf weight. tf weight increases with the number of occurrences within a document idf weight increases with the rarity of the term in the collection

Binary → count → weight matrix Sec. 6.3 Binary → count → weight matrix According to this, “Brutus” is more important than “Caesar”. In the final scene, Brutus committed suicide and Mark Antony describes him "the noblest Roman of them all“. Each document is now represented by a real-valued vector of tf-idf weights ∈ R|V| These documents sit in a vector space of V dimensions.

Documents as vectors So we have a |V|-dimensional vector space Sec. 6.3 Documents as vectors So we have a |V|-dimensional vector space Terms are axes of the space Documents are points or vectors in this space Very high-dimensional: tens of millions of dimensions when you apply this to a web search engine These are very sparse vectors - most entries are zero.

Sec. 6.3 Queries as vectors Do the same for queries: represent them as vectors in the space Rank documents according to their proximity to the query in this space proximity = similarity of vectors

Euclidean distance is a bad idea Sec. 6.3 Euclidean distance is a bad idea The Euclidean distance between q and d2 is large even though the distribution of terms in the query q and the distribution of terms in the document d2 are very similar. Euclidean distance is large for vectors of different lengths.

Use angle instead of distance Sec. 6.3 Use angle instead of distance Take a document d and append it to itself. Call this document d′. Semantically d and d′ have the same content The Euclidean distance between the two documents is quite large The angle between the two documents is 0, corresponding to maximal similarity. Lesson: Rank documents according to angle with query.

Sec. 6.3 From angles to cosines Rank documents in decreasing order of the angle between query and document Rank documents in increasing order of cosine(query,document) Cosine is a monotonically decreasing function for the interval [0o, 180o] As the angle increases, its cosine decreases.

Sec. 6.3 Length normalization A vector can be (length-) normalized by dividing each of its components by its length – for this we use the L2 norm: Dividing a vector by its L2 norm makes it a unit length vector on surface of unit hypersphere Effect on the two documents d and d′ (d appended to itself) from earlier slide: they have identical vectors after length-normalization. Long and short documents now be compared

cosine(query,document) Sec. 6.3 cosine(query,document) See Law of Cosines (Cosine Rule) wikipedia page qi is the tf-idf weight of term i in the query di is the tf-idf weight of term i in the document cos(q,d) is the cosine similarity of q and d , i.e., the cosine of the angle between q and d.

Cosine similarity illustrated

Cosine similarity amongst 3 documents Sec. 6.3 Cosine similarity amongst 3 documents Emily Brontë 1847 Jane Austen 3 novels SaS: Sense and Sensibility PaP: Pride and Prejudice WH: Wuthering Heights 1811 1813 term SaS PaP WH affection 115 58 20 jealous 10 7 11 gossip 2 6 wuthering 38 Term frequencies (counts) To simplify this example, we don’t do idf weighting.

3 documents example Log frequency weighting After length normalization Sec. 6.3 3 documents example > SaSl=(3.06^2 + 2^2 + 1.3^2)^.5 > c(3.06, 2, 1.3, 0)/SaSl [1] 0.789 0.515 0.335 0.0 Log frequency weighting After length normalization term SaS PaP WH affection 3.06 2.76 2.30 jealous 2.00 1.85 2.04 gossip 1.30 1.78 wuthering 2.58 term SaS PaP WH affection 0.789 0.832 0.524 jealous 0.515 0.555 0.465 gossip 0.335 0.405 wuthering 0.588 cos(SaS,PaP) ≈ 0.789 × 0.832 + 0.515 × 0.555 + 0.335 × 0.0 + 0.0 × 0.0 ≈ 0.94 high cos means low angle cos(SaS,WH) ≈ 0.79 cos(PaP,WH) ≈ 0.69 Why do we have cos(SaS,PaP) > cos(SaS,WH)? SaS and PaP were written by the same author.

Variations Sec. 6.4 n default is just term frequency ltc is best known form of weighting

Summary – vector space ranking Represent the query as a weighted tf-idf vector Represent each document as a weighted tf-idf vector Compute the cosine similarity score for the query vector and each document vector Rank documents with respect to the query by score Return the top 10 to the user