TF-IDF: Distinguishing frequency in document from prevalence in language

Hand-counted reverse document frequency, which describes the impact of smoothing, reclassification and word sheet updates.

Thematic shorts • IntroductionCollate in 2 self-measured2 First-hand sources
Start Body
Learning objectives and first steps2 objectives 2 first fixes

Try to do it after reading

  • Hand-counted reverse document frequency, which describes the impact of smoothing, reclassification and word sheet updates.
  • Check the input, label and evaluation conditions in the example

Suggested first

  • Text Tasks and Language Expressions
  • Conditional probability and vector calculations

Common words versus distinguishing words

(b) A term appears repeatedly in the current article, possibly as a subject line; However, if it appears in all articles, the ability to separate documents is limited. The word frequency is combined with the reverse document frequency: the former comes from a single document and the latter comes from the coverage of training materials. They're not the same denominator.

A common smooth form uses the total number of documents to be divided by the number of documents to include the word to be added by adding a logarithm to the number of documents to be added. Different libraries and teaching materials may use different smoothing and word-frequency variations, so that the configuration cannot be omitted by simply writing an algorithm name. Ultimately, it is possible to standardize the two-dimensional vectors of each document, which in turn changes the numerical scale.

Examples of four documents

Of the four training articles, “models” appeared in all four, and “ball bats” appeared in only one. Using the smooth format described above, the reverse document frequency of the model is one, with a ball bat of approximately 1.916. If a single entry appears, the weight of the game is higher before reclassification. If the ball bat repeats ten times, the original word frequency multiplied will continue to be enlarged; The use of logarithm frequency reduces the effect of repeating a stack of words.

The number of documents containing a word is counted here, not the total number of occurrences of the word in the language material. One article repeats a hundred hits, increasing the frequency of its documents by one. When a small sample is tested, a document that repeats words should be prepared to confirm that the total word frequency has not been incorrectly used as the reverse document frequency denominator.

Update and evaluate boundaries

The phrase sheets and reverse document frequencies should be combined by a training set. The inclusion of test text in the statistics will use future distribution information; Even without reading test labels, the evaluation conditions changed. You can choose to freeze statistics or update them regularly as a whole after adding documents online, but new and old vectors should be used in a consistent statistical version, especially if they are not randomly commingled in vector resemblance searches.

High weights do not mean that words are really important. A spelling error, because it rarely occurs, may also be given a high weight. The minimum document frequency, text standardization and word check could improve this, but it was not possible to delete justly rare and key professional terms. It should be combined with the actual retrieval of errors and classification weights, rather than simply seeking to achieve even distribution of weights.

idf(t)=ln(N+1df(t)+1)+1

Check understanding

Do you repeat a word 10 times in the same document and increase the frequency of the document 10 times?

Not ten more. Document frequency count of the number of documents containing the word, which is contributed at most once; Duplicate within a document is handled in the word frequency part.

Both systems are called TF-IDF. Can vector values be compared directly?

Not necessarily. Smooth formulas, word frequency variations, phrase sheets and reclassifications may be different. The complete configuration should be kept and checked on a single item.

Sources and reconciliations

Definitions, methods and interfaces are available.

  1. scikit-learn — Feature extraction
  2. Jurafsky and Martin — Embeddings

Figures and calculations are reorganized according to this chapter. Mathematical measurements, framework operations and real business effects are described separately in the body of the text.

← Back to the knowledge directory
Ask Max Ask about this site
Ask Max ↗

Opening the assistant…

Paper figure

Photo comments

LEAVE A NOTE

About this photograph

Connecting to the discussion board…

    Comments become public after moderation. You can delete your own comments from this browser.
    No email is required. Clearing cookies prevents this browser from claiming earlier comments.

    MAX WANG / INDEX

    Find something

    Enter a keyword, or explore the directory below.