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 qwen3-coder-next
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 qwen3-coder-next. After the conversation, we show detailed score cards for this run.
Score cards for qwen3-coder-next for Text Data EDA in Python
Total score: 6/10
Task Completion: 2/2
ExcellentAll four requested analyses were attempted and completed: category counts, text length distribution, top word frequencies, and TF-IDF keywords per category.
Execution Correctness: 1/2
Needs workThe code is mostly runnable, but there is a seaborn legend warning and the TF-IDF keyword logic includes some weak terms and a duplicated top-word issue in the narrative, suggesting imperfect implementation.
Output Quality: 2/3
GoodThe notebook produced the expected outputs, including the count summary, a distribution plot, a top-20 frequency list, and a 40-row TF-IDF keyword table. However, the expected box plot and horizontal bar chart were not explicitly shown, and the TF-IDF presentation is somewhat inconsistent.
Reasoning Quality: 1/2
Needs workThe reasoning is generally coherent, but it overstates completeness at points and does not align perfectly with the stated expected outcomes, especially for the missing box plot and horizontal bar chart.
Reliability: 0/1
Needs workThe workflow is somewhat fragile: it relies on ad hoc narrative claims, includes a plotting warning, and the TF-IDF ranking method is not clearly robust or fully validated.
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.