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 | 9/10 | 2/2 | 2/2 | 2/3 | 2/2 | 1/1 | Open gemma4:31b conversation |
| qwen3-coder-next | 9/10 | 2/2 | 2/2 | 3/3 | 1/2 | 1/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 gpt-oss:120b
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 gpt-oss:120b. After the conversation, we show detailed score cards for this run.
Score cards for gpt-oss:120b for Text Data EDA in Python
Total score: 10/10
Task Completion: 2/2
ExcellentAll major requested steps were completed: dataset loading, document count per category, text-length distribution plot, top word frequencies, and TF-IDF keyword extraction.
Execution Correctness: 2/2
ExcellentThe shown code is syntactically coherent and the outputs are consistent with the operations performed, so it is likely runnable.
Output Quality: 3/3
ExcellentThe outputs match the expected outcomes semantically, including the category count table, length distribution plot, top-20 word frequency table, and per-category TF-IDF keyword tables.
Reasoning Quality: 2/2
ExcellentThe workflow uses appropriate NLP/EDA methods and the explanations align with the generated outputs without obvious logical errors.
Reliability: 1/1
ExcellentThe workflow is reasonably robust, with standard library usage and sensible preprocessing choices; no major hallucinations or unsafe steps are evident.
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.