An AI-powered data science agent that automatically analyzes any CSV dataset using Claude AI + Machine Learning. Upload a dataset, ask a question in plain English, and the agent decides which tools to use, runs the analysis, trains ML models, and delivers insights — all autonomously.
This project is built on the Model Context Protocol (MCP) architecture:
User (Natural Language)
↓
Streamlit Web UI
↓
Claude AI (Brain)
↓
MCP Tool Router
↓
┌───────────────────────────────────┐
│ describe_dataset │
│ run_python_analysis │
│ generate_chart │
│ train_ml_model │
│ feature_importance │
└───────────────────────────────────┘
Claude acts as the reasoning engine — it reads your question, decides which tools to call, chains them together intelligently, and explains the results in simple business terms.
- Automated Data Cleaning — Auto-fixes missing values, removes duplicates, detects outliers and standardizes column names before analysis
- Intelligent Tool Routing — Claude only calls the tools needed for your question, not all of them
- Statistical Analysis — Correlations, distributions, and relationships between variables
- Auto ML Training — Trains a Random Forest model and returns R² score and error metrics
- Feature Importance — Ranks which variables drive your target metric the most
- Chart Generation — Scatter plots, bar charts, and correlation heatmaps on demand
- Session Isolation — Each session uses its own data, no cross-session chart mixing
- Rate Limit Handling — Friendly messages instead of raw error traces
- API Key Input — Paste your Anthropic key directly in the UI, no
.envneeded
| Layer | Technology |
|---|---|
| AI Brain | Claude (Anthropic) |
| Agent Protocol | MCP (Model Context Protocol) |
| ML Engine | Scikit-learn (Random Forest) |
| Data Processing | Pandas, NumPy |
| Visualization | Matplotlib, Seaborn |
| Web UI | Streamlit |
| Language | Python |
data-science-agent/
├── app.py # Streamlit web UI + agentic loop
├── requirements.txt # Python dependencies
├── .env # Your API key (not committed)
├── .gitignore
├── demo.gif # Demo recording
├── mcp_server/
│ └── server.py # MCP server with all 5 tools
├── uploads/ # Uploaded CSV files (not committed)
└── outputs/ # Generated charts (not committed)
git clone https://github.com/yourusername/data-science-agent.git
cd data-science-agentpython -m venv venv
# Windows
venv\Scripts\activate
# Mac/Linux
source venv/bin/activatepip install -r requirements.txt👉 https://console.anthropic.com → API Keys → Create Key
streamlit run app.pyhttp://localhost:8501
Paste your Anthropic API key in the sidebar, upload any CSV, and start asking questions!
| Question | Tools Used |
|---|---|
What columns are in this dataset? |
describe_dataset |
What drives revenue the most? |
run_python_analysis |
Show me a correlation heatmap |
generate_chart |
Train a model to predict revenue |
train_ml_model |
Which features matter most? |
feature_importance |
Give me a full analysis |
All tools |
Inspects the CSV and returns shape, column names, data types, missing values, and sample rows.
Computes correlations between all numeric columns and the target variable. Labels each as strong/moderate/weak positive or negative.
Generates scatter plots, bar charts, or correlation heatmaps. Returns base64-encoded image — no disk dependency.
Trains a Random Forest Regressor with an 80/20 train-test split. Returns R² score, MAE, and model quality rating.
Uses Random Forest feature importances to rank which variables drive the target metric. Labels each as High / Medium / Low impact.
A sample dataset is included to test the agent:
month, marketing_spend, store_count, avg_price, revenue
Jan, 5000, 10, 25.5, 32000
...
Try asking: Give me a full analysis with revenue as the target.
Create a .env file in the root folder (optional — you can also paste the key in the UI):
ANTHROPIC_API_KEY=sk-ant-your-key-here
- Automated Data Cleaning — auto-detect and fix missing values, duplicates, outliers and column formatting before analysis
- Support for larger real-world datasets (sales, healthcare, finance)
- Time series analysis
- Multi-file upload and joins
- Auto-generated PDF report of full analysis
MIT License — feel free to use, modify, and share.
Built by Kunal — connecting LLMs with ML automation to build intelligent data tools.
