--- title: Data Analyzer Agent emoji: 📊 colorFrom: blue colorTo: green sdk: gradio sdk_version: 5.29.0 python_version: "3.10" app_file: app.py pinned: false --- # Data Analyzer Agent AI-powered data analysis assistant that generates and executes Python code to analyze data and create visualizations. [![Live Demo](https://img.shields.io/badge/Live%20Demo-Try%20It-blue?style=for-the-badge&logo=huggingface)](https://davidleocadio94dlai-data-analyzer-agent.hf.space) ## Features - **AI-Powered Analysis** — Describe what you want in natural language, get executable Python code and results - **Secure Code Execution** — E2B sandbox isolates code execution for safe, reliable operation - **Data Visualizations** — Generate matplotlib and seaborn charts displayed directly in chat - **Statistical Analysis** — Compute distributions, correlations, descriptive statistics, and more ## Tech Stack ![Gradio](https://img.shields.io/badge/Gradio-FF7C00?style=flat&logo=gradio&logoColor=white) ![OpenAI](https://img.shields.io/badge/OpenAI-412991?style=flat&logo=openai&logoColor=white) ![E2B](https://img.shields.io/badge/E2B-000000?style=flat&logo=e2b&logoColor=white) ![Python](https://img.shields.io/badge/Python-3776AB?style=flat&logo=python&logoColor=white) ![HuggingFace](https://img.shields.io/badge/HuggingFace-FFD21E?style=flat&logo=huggingface&logoColor=black) - **AI Model:** OpenAI GPT-4 - **Code Execution:** E2B Code Interpreter - **Interface:** Gradio - **Deployment:** HuggingFace Spaces ## Getting Started ### Local Development ```bash # Clone the repository git clone https://github.com/davidleocadio94/data-analyzer-agent.git cd data-analyzer-agent # Install dependencies pip install -r requirements.txt # Set up environment variables export OPENAI_API_KEY=your-openai-key export E2B_API_KEY=your-e2b-key # Run the application python app.py ``` Visit `http://localhost:7860` to use the chat interface. ## Example Queries Try these prompts to explore the agent's capabilities: - *"Generate 100 random numbers from a normal distribution and plot a histogram"* - *"Calculate the mean, median, and standard deviation of [23, 45, 67, 89, 12, 34, 56]"* - *"Create a scatter plot showing the relationship between x and y where y = 2x + noise"* - *"Analyze the correlation between two random variables and visualize it"* ## Project Structure ``` data-analyzer-agent/ ├── app.py # Gradio chat interface ├── src/ │ ├── agent.py # OpenAI agent with tool execution │ └── tools.py # E2B code interpreter tool ├── requirements.txt # Python dependencies └── README.md ``` --- Built as part of [DeepLearning.AI](https://www.deeplearning.ai/) coursework