TDS Project 2 Β· Drop in any CSV. Get statistics, visualizations, and an AI-generated narrative β fully automated.
- Overview
- How It Works
- Repository Structure
- Datasets Analyzed
- Pipeline Breakdown
- Getting Started
- Output Files
- Technical Architecture
- Sample Results
Autolysis is a zero-configuration data analysis pipeline. Pass it any CSV file and it will:
- Load & clean the data (handles encoding quirks, missing values, type inference)
- Analyze it β summary statistics, correlations, and IQR-based outlier detection
- Visualize β correlation heatmaps, outlier bar charts, and distribution plots saved as PNGs
- Narrate β calls an LLM (GPT-4o-mini via AI Proxy) to generate a written story from the findings
- Report β outputs a fully-formed
README.mdwith embedded charts and narrative
No configuration files. No manual steps. One command.
python autolysis.py dataset.csvCSV Input
β
βΌ
βββββββββββββββββββββββ
β Data Loading β pandas Β· ISO-8859-1 encoding support
ββββββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββββββ
β Statistical β describe() Β· isnull() Β· .corr()
β Analysis β
ββββββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββββββ
β Outlier Detection β IQR method (Q1 - 1.5ΓIQR / Q3 + 1.5ΓIQR)
ββββββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββββββ
β Visualization β seaborn Β· matplotlib β PNG files
ββββββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββββββ
β LLM Narrative β GPT-4o-mini via AIPROXY_TOKEN
ββββββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββββββ
β README Generation β Markdown report with embedded visuals
βββββββββββββββββββββββ
Tools-In-Data-Science-Project-2/
β
βββ autolysis.py # Core analysis engine (single-file, self-contained)
β
βββ goodreads/ # Analysis output β Goodreads dataset
β βββ README.md
β βββ correlation_matrix.png
β βββ outliers.png
β βββ distribution_*.png
β
βββ happiness/ # Analysis output β World Happiness dataset
β βββ README.md
β βββ correlation_matrix.png
β βββ outliers.png
β βββ distribution_*.png
β
βββ media/ # Analysis output β Media consumption dataset
β βββ README.md
β βββ correlation_matrix.png
β βββ outliers.png
β βββ distribution_*.png
β
βββ LICENSE # MIT
βββ README.md # You are here
Book ratings, author profiles, genre distribution, and publication trends. Key questions: What makes a book highly rated? Which authors dominate by volume vs. quality?
Country-level happiness scores correlated against GDP, social support, health, freedom, and corruption. Key questions: What factors most strongly predict national happiness?
Media consumption data β views, ratings, and genre breakdown. Key questions: Are certain genres consistently better rated? What does engagement look like across media types?
Runs df.describe() for summary stats, counts nulls per column, and computes a full Pearson correlation matrix on all numeric columns.
Uses the IQR method β values beyond Q1 β 1.5ΓIQR or Q3 + 1.5ΓIQR are flagged as outliers, counted per column.
Generates three charts per dataset:
- Correlation Heatmap β
Bluespalette, annotated cells - Outlier Bar Chart β only rendered when outliers are detected
- Distribution Plot β KDE-smoothed histogram of the first numeric column
Posts to the AI Proxy endpoint (aiproxy.sanand.workers.dev) with GPT-4o-mini. Passes summary stats and missing value counts as context. Returns a narrative string appended to the report.
headers = {"Authorization": f"Bearer {token}"}
data = {"model": "gpt-4o-mini", "messages": [...], "max_tokens": 1000}
response = requests.post(api_url, headers=headers, data=json.dumps(data))Assembles a Markdown report with embedded PNG references, summary stat tables (via .to_markdown()), and the LLM narrative.
Dependencies are declared inline via PEP 723 script metadata and can be installed with:
pip install pandas seaborn matplotlib numpy scipy openai scikit-learn requestsThe LLM narrative step requires an AI Proxy token:
export AIPROXY_TOKEN=your_token_hereThe tool uses
https://aiproxy.sanand.workers.devβ a cost-efficient proxy to OpenAI's API. Without a token, the analysis still runs; only the narrative generation step fails gracefully.
python autolysis.py path/to/your/dataset.csvOutput is written to an output/ directory created automatically in the current working directory.
| File | Description |
|---|---|
README.md |
Full analysis report with embedded charts and LLM narrative |
correlation_matrix.png |
Heatmap of Pearson correlations between numeric columns |
outliers.png |
Bar chart of outlier counts per column (if any found) |
distribution_<col>.png |
KDE histogram of the first numeric column |
| Component | Technology |
|---|---|
| Data loading | pandas (ISO-8859-1 encoding) |
| Statistics | pandas, numpy |
| Outlier detection | IQR method via numpy |
| Visualizations | seaborn, matplotlib |
| LLM integration | OpenAI GPT-4o-mini via AI Proxy |
| Report generation | Python file I/O + Markdown |
| CLI | argparse / sys.argv |
| Dependency spec | PEP 723 inline script metadata |
Happiness Dataset β Notable Correlation: GDP per capita and Life Ladder (happiness score) show strong positive correlation, confirming economic prosperity as a primary driver of reported well-being across nations.
Goodreads Dataset β Notable Finding: Books with higher ratings tend to have more text reviews than star-only ratings, suggesting engaged readers leave qualitative feedback more than disengaged ones.
Media Dataset β Notable Finding: Overall quality ratings cluster tightly regardless of language, suggesting audience satisfaction is driven more by content quality than production origin.
Aman Mani Tiwari github.com/AmanManiTiwari
MIT β see LICENSE for details.
Built as part of the Tools in Data Science course. Analysis powered by the GitHub API, OpenAI GPT-4o-mini, and standard Python data science libraries.