Pointwise mutual information on text
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Pointwise mutual information (PMI) is a measure used in information theory and natural language processing to quantify the association between two random events. In the context of text analysis, PMI is particularly useful for identifying the strength of association between words or phrases within a corpus. This metric helps in understanding how much the presence of one word tells us about the presence of another, relative to a baseline of their independent occurrences.
Technical Explanation
PMI between two words, and , is defined mathematically as:
• is the joint probability of both words occurring together. • and are the individual probabilities of each word occurring independently.
In practice, these probabilities are often estimated from a corpus:
• is calculated as the frequency of divided by the total number of words in the corpus. • is calculated as the frequency of the two words occurring together, divided by the total number of word pairs.
Interpretation
• Positive PMI: Indicates that the two words co-occur more frequently than would be expected by chance. • Zero PMI: Suggests that the words co-occur at a rate that is expected by chance. • Negative PMI: Implies that the words co-occur less frequently than would be expected by chance.
High PMI values can be indicative of collocations or common expressions, while low (or negative) PMI values may suggest some degree of independent behavior between the words.
Considerations
- Sparsity: PMI can be sensitive to low-frequency events. Words that appear rarely may result in extreme PMI values.
- Normalization: Variants like normalized PMI (NPMI) attempt to adjust PMI values within the range of -1 and 1 for easier interpretation:
Example
Consider a small corpus:
• "cat and dog" • "cat and mouse" • "dog barks" • "mouse and cheese"
Calculate the PMI for the word pair "cat" and "dog":
- Total Word Count = 11
- Frequency of "cat" = 2
- Frequency of "dog" = 2
- Frequency of "cat and dog" = 1
Applications
- Collocation Extraction: PMI is a standard statistical measure for identifying collocations in texts, such as "New York" or "natural language."
- Sentiment Analysis: In sentiment analysis, PMI can help in assessing the sentiment association between words.
- Information Retrieval: It assists in retrieving documents where certain word pairs are more likely to appear together, enhancing relevancy.
Limitations
• Bias Towards Rare Events: PMI tends to favor infrequent but coincidental word pairs, requiring careful handling, especially in large corpora. • Absolute Values: High absolute values can be misleading, especially if the words involved are of low frequency.
Summary Table
| Aspect | Explanation/Value |
| Formula | |
| Range | to |
| Positive Value | Indicative of association |
| Zero Value | Indicative of independence |
| Negative Value | Indicative of repulsion |
| Normalization | NPMI adjusts within -1 to 1 range: |
| Applications | Collocation detection, Sentiment analysis, Information retrieval |
| Limitations | Sensitivity to rare events |
In conclusion, pointwise mutual information is a versatile and informative metric utilized in various fields of text analysis. It is crucial to consider both its strengths in identifying meaningful associations and its potential limitations due to rare word occurrences, ensuring that results are both accurate and applicable.
Related reading
- POS tagging in spanish with NLTK?
- Predicting a probability of a sentence using tensorflow
- Predicting Missing Words in a sentence - Natural Language Processing Model
- Predicting next word using the language model tensorflow example
- Predicting phrases instead of just next word
- Prevent over-fitting of text classification using Word embedding with LSTM
- Python - A way to learn and detect text patterns?
- Python - Calculate Hierarchical clustering of word2vec vectors and plot the results as a dendrogram
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.