Hypothesis Testing in Python (t-test, ANOVA)
Perform t-tests, chi-square tests, and ANOVA using real data to answer business questions — guided by an AI data analyst.
What this AI workflow does
This AI Data Analyst workflow loads the Titanic training dataset from a URL and runs a two-sample t-test to compare average age between survivors and non-survivors. It performs a chi-square test of independence to assess whether survival is associated with passenger class. It runs a one-way ANOVA to test whether fare differs across the three passenger classes and summarizes the results in plain language.
Who this example is for
This is for analysts and students who need a concrete, code-driven example of hypothesis testing on a real dataset. It helps anyone answering business-style questions with statistical tests and interpretable outputs in a notebook.
Expected analysis outcomes
These are the results the AI workflow is expected to generate.
- t-test result comparing survivor vs non-survivor age with p-value and interpretation
- chi-square test result for survival vs passenger class independence with p-value and interpretation
- one-way ANOVA result for fare differences across classes with p-value and interpretation
- plain-language summary table consolidating all three hypothesis tests
Tools and libraries used
Main Python packages and tooling used to run this AI data analysis task.
- pandas
- numpy
- scipy
- statsmodels
- 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 titanic data from https://raw.githubusercontent.com/pplonski/datasets-for-start/refs/heads/master/Titanic/train.csv and test whether average age differs significantly between survivors and non-survivors using a t-test
- 2test whether survival rate is independent of passenger class using a chi-square test
- 3test whether fare differs significantly across the three passenger classes using ANOVA
- 4summarise all three test results and their business interpretation
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 |
|---|---|---|---|---|---|---|---|
| gemma4:31b | 10/10 | 2/2 | 2/2 | 3/3 | 2/2 | 1/1 | Open gemma4:31b conversation |
| 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-coder-next | 10/10 | 2/2 | 2/2 | 3/3 | 2/2 | 1/1 | Open qwen3-coder-next conversation |
| qwen3.5:397b | 10/10 | 2/2 | 2/2 | 3/3 | 2/2 | 1/1 | Open qwen3.5:397b 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.5:397b
This run uses AI with a step-by-step list of prompts to perform the analysis task Hypothesis Testing in Python (t-test, ANOVA). Below, you can review the full conversation generated with qwen3.5:397b. After the conversation, we show detailed score cards for this run.
Score cards for qwen3.5:397b for Hypothesis Testing in Python (t-test, ANOVA)
Total score: 10/10
Task Completion: 2/2
ExcellentAll three requested hypothesis tests were performed and the results were summarized with interpretation.
Execution Correctness: 2/2
ExcellentThe code shown is syntactically valid and the outputs indicate it ran successfully, with no major execution errors.
Output Quality: 3/3
ExcellentThe outputs match the expected outcomes: significant t-test, chi-square, and ANOVA results, plus a plain-language summary of each test.
Reasoning Quality: 2/2
ExcellentThe interpretations are correct and aligned with the statistical results, including business-relevant conclusions.
Reliability: 1/1
ExcellentThe workflow is consistent and uses standard statistical tests appropriately, with only a minor non-critical seaborn 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.