Text Data EDA in Python
Explore a text dataset with word frequency analysis, top bigrams, text length distribution, and TF-IDF keyword extraction.
What this AI workflow does
This AI Data Analyst workflow loads a 20 Newsgroups subset from scikit-learn with four categories and summarizes document counts by category. It analyzes basic text characteristics by plotting text length distributions across categories and computing the most frequent words after stopword removal. It also extracts TF-IDF keywords per category to surface terms that distinguish each group.
Who this example is for
This is for analysts and data scientists who need a repeatable exploratory data analysis template for multi-class text datasets. It helps validate dataset balance and inspect category-specific vocabulary before building NLP models.
Expected analysis outcomes
These are the results the AI workflow is expected to generate.
- Bar chart of document counts per category
- Box plot of text lengths per category
- Horizontal bar chart of top word frequencies after stopword removal
- Table of top TF-IDF keywords per category
Tools and libraries used
Main Python packages and tooling used to run this AI data analysis task.
- scikit-learn
- pandas
- numpy
- matplotlib
- seaborn
Prompt sequence
This is the exact list of prompts used in this workflow. The same prompt sequence is sent to each model so outputs and scores can be compared fairly.
- 1load 20 newsgroups dataset (20 Newsgroups from sklearn) with 4 categories and show document count per category fetch_20newsgroups(categories=['sci.space','rec.sport.hockey','comp.graphics','talk.politics.misc'])
- 2plot text length distribution across categories
- 3show top 20 most frequent words after removing stopwords
- 4extract top TF-IDF keywords per category
Model Comparison
We compared several LLM models on the same analysis task. The table below shows their scores side by side. You can also open each model run to check the full conversation and notebook results.
| Model Source | Score | Task | Execution | Output | Reasoning | Reliability | Run |
|---|---|---|---|---|---|---|---|
| glm-5.1 | 10/10 | 2/2 | 2/2 | 3/3 | 2/2 | 1/1 | Open glm-5.1 conversation |
| gpt-5.4 | 10/10 | 2/2 | 2/2 | 3/3 | 2/2 | 1/1 | Open gpt-5.4 conversation |
| gpt-oss:120b | 10/10 | 2/2 | 2/2 | 3/3 | 2/2 | 1/1 | Open gpt-oss:120b conversation |
| qwen3.5:397b | 10/10 | 2/2 | 2/2 | 3/3 | 2/2 | 1/1 | Open qwen3.5:397b conversation |
| gemma4:31b | 8/10 | 2/2 | 2/2 | 2/3 | 1/2 | 1/1 | Open gemma4:31b conversation |
| qwen3-coder-next | 6/10 | 2/2 | 1/2 | 2/3 | 1/2 | 0/1 | Open qwen3-coder-next conversation |
How scoring works
Each run is graded on five dimensions:
- Task Completion (0-2): how fully the workflow answered the requested analysis task and completed required steps.
- Execution Correctness (0-2): whether generated code is correct, consistent, and likely runnable without major fixes.
- Output Quality (0-3): how well tables, charts, and results match the expected analytical outcomes.
- Reasoning Quality (0-2): clarity and correctness of interpretation, explanation, and conclusions.
- Reliability (0-1): robustness of the run, including low hallucination risk and stable behavior.
The final score is the sum of these dimensions, so total score = 0-10. Higher values indicate more complete, correct, and reliable notebook results for this workflow.
AI Analysis with gemma4:31b
This run uses AI with a step-by-step list of prompts to perform the analysis task Text Data EDA in Python. Below, you can review the full conversation generated with gemma4:31b. After the conversation, we show detailed score cards for this run.
Score cards for gemma4:31b for Text Data EDA in Python
Total score: 8/10
Task Completion: 2/2
ExcellentAll four requested analyses were attempted: category counts, text length distribution, top word frequencies, and TF-IDF keywords per category.
Execution Correctness: 2/2
ExcellentThe code shown is syntactically coherent and the outputs indicate it ran successfully, including the dataset load, plot generation, frequency table, and TF-IDF results.
Output Quality: 2/3
GoodThe notebook produced the expected core outputs, but the TF-IDF result is a table of top 10 keywords per category rather than the requested top 5, and there is no explicit bigram analysis despite the workflow description mentioning it.
Reasoning Quality: 1/2
Needs workThe reasoning is generally sensible, but it includes unnecessary detours and some mismatch between the stated goal and the implemented outputs, especially around keyword count and the absent bigram step.
Reliability: 1/1
ExcellentThe workflow is mostly consistent and runnable, though it relies on notebook state and includes extra, partially mismatched analysis steps that reduce robustness.
Try MLJAR Studio
Run the same type of AI-powered data analysis on your own datasets with conversational notebooks in MLJAR Studio.
Explore More AI Analysis Examples
Discover additional workflows across categories. Each example includes prompts, conversation outputs, and model-level scoring so you can compare approaches and results.