Charta is on Google Play: practise on the go. Get the app

Explain techniques for extracting, choosing and engineering features from text data

CFA® Level II · Quantitative Methods · Big Data Projects · L2.QM.7.e

The idea

Text is turned into features in stages. Tokenisation splits it into words; normalisation lowercases, removes stop words, and applies stemming or lemmatisation. A bag of words records which tokens occur, ignoring order, and a document term matrix has one row per document and one column per token. N-grams such as bigrams keep short sequences like "not profitable". Feature selection uses frequency measures: term frequency is a token's count in a sentence divided by the sentence's tokens, document frequency is the share of sentences containing it, and TF-IDF is TF × ln(1 ÷ DF). Feature engineering adds numbers, named entities and parts of speech. The usual slip is swapping rows and columns.

Formulas

TF-IDF

TF-IDF = TF × ln(1 ÷ DF)

TF
the term's count divided by the tokens in the sentence
DF
the share of sentences that contain the term
ln
the natural logarithm

A term in every sentence scores zero. A rare term that appears often in one sentence scores high.

In the app: 3 practice questions on this outcome, a narrated walkthrough with diagrams, spaced review that brings it back before you forget it.

Take the free diagnostic →

More in Big Data Projects