liveBook · Manning

Frequency analysis

As explained in Starting Data Analytics with Generative AI and Python

Frequency-based text analysis infers textual meaning or themes from the occurrence counts of words, phrases, or terms.

What do customers most often praise or complain about? Frequency analysis counts occurrences of items; in text, those items can be words or phrases. Frequent terms offer a quick view of recurring topics without reading every review, though counts alone are clues rather than a full interpretation. section 5.3 section 5.1.1

In reviews, repeated mentions of “battery life” might point to a valued feature, while frequent delivery-related phrases can highlight a common concern. Comparing mentions over time can also suggest changing preferences. A frequent word identifies a topic, but it does not by itself establish whether customers like or dislike it. section 5.3.1 section 5.3

A practical workflow with a generative AI assistant:

  • For a small sample, paste the reviews into a chat and ask for a frequency analysis. Distinguish common grammatical words from terms that describe the reviews’ content. section 5.3.2
  • For a larger dataset, ask for code and specify the DataFrame, text column, file path, and language. Otherwise, generated code may use generic names or unsuitable defaults. section 5.2.2 section 5.3.4
  • Tokenize the text, normalize capitalization, filter punctuation and language-appropriate stopwords, and count the remaining words. Check the generated tokenizer settings: mentioning Portuguese in the prompt does not guarantee that the code uses Portuguese settings. section 5.3.4
  • Inspect the counts and phrases, translate unfamiliar terms if needed, and use follow-up prompts to refine the analysis. A word cloud can make frequent terms visible, but the underlying counts remain important. section 5.3.2 section 5.3.6

Delivery themes in Portuguese reviews

A direct analysis of a small review sample found common grammatical words as well as more informative terms such as “antes” (before) and “prazo” (deadline). In a separate output, recurring three-word groups included “chegou, antes, prazo” (arrived, before, deadline), suggesting a delivery-timing theme. Inspect the reviews before treating that theme as a complete account of customer satisfaction. section 5.3.2 section 5.3.6

('chegou', 'antes', 'prazo') - (arrived, before, deadline)
('bem', 'antes', 'prazo') - (well, before, deadline)
('entregue', 'antes', 'prazo') - (delivered, before, deadline)
('produto', 'chegou', 'antes') - (product, arrived, before)
('entrega', 'antes', 'prazo') - (delivery, before, deadline)
('chegou', 'bem', 'antes') - (arrived, well, before)
('produto', 'entregue', 'antes') - (product, delivered, before)
('entrega', 'super', 'rápida') - (delivery, super, fast)
('antes', 'prazo', 'previsto') - (before, deadline, expected)
('produto', 'ótima', 'qualidade') - (product, great, quality)

Compare the translated three-word groups to see how phrases add context to individual word counts. section 5.3.6

Treat AI-generated counts, translations, and code as results to check, not automatic truth. Messy spelling, punctuation, and capitalization can affect analysis, while frequent terms can miss meaning that depends on context. Inspect the preprocessing and compare interpretations with review examples before using them for decisions. section 5.0 section 5.3.4 section 5.1.1

How Starting Data Analytics with Generative AI and Python covers it

How deep it goes
Walks through direct prompting, language-specific preprocessing, counting, translation, and visualization, while highlighting a tokenizer-setting error.
Examples
Analyzes Portuguese customer reviews and translates recurring delivery-related three-word groups.
What you can do after
Apply it via generative AI and Python to count review terms and interpret the output cautiously.
How it connects
Connects frequency analysis with tokenization, stopword removal, co-occurrence analysis, and sentiment analysis.

Also explained in

Compare how 2 books explain frequency analysis →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Starting Data Analytics with Generative AI and Python. The section links point to the parts of the book it draws on.