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 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 four requested EDA steps were completed: category counts, text-length distribution, top word frequencies, and TF-IDF keywords per category.
Execution Correctness: 2/2
ExcellentThe code shown is coherent and likely runnable, with appropriate imports and valid sklearn/pandas/nltk/seaborn usage. No major syntax or logic errors are evident from the provided notebook content.
Output Quality: 3/3
ExcellentThe outputs match the expected outcomes semantically: a count table, a length-distribution plot, a top-20 frequency table, and TF-IDF keyword tables for each category. The results are displayed clearly and are consistent with the prompts.
Reasoning Quality: 2/2
ExcellentThe workflow follows a sensible EDA progression and uses appropriate methods for each task. The TF-IDF and frequency extraction logic is clear and aligned with the requested analysis.
Reliability: 1/1
ExcellentThe workflow is reasonably robust, though it relies on notebook state carrying variables forward and includes repeated display cells and a harmless seaborn deprecation warning.
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.