Spaces:
Sleeping
Download README.md from 01ammu/data-cleaning-openenv: direct link, hf CLI and curl.
- Browser
- Download file 19 kB
-
https://huggingface.co/spaces/01ammu/data-cleaning-openenv/resolve/main/README.md
- Command line
-
hf download hf://spaces/01ammu/data-cleaning-openenv/README.md
-
curl -L -o README.md https://huggingface.co/spaces/01ammu/data-cleaning-openenv/resolve/main/README.md
title: Data Cleaning Openenv - AI-Powered Platform
emoji: ๐งน
colorFrom: blue
colorTo: green
sdk: docker
pinned: false
tags:
- openenv
- reinforcement-learning
- data-cleaning
- full-stack
- devops
๐งน AI-Powered Data Cleaning Platform
An enterprise-grade, full-stack RL-powered data cleaning platform built on OpenEnv with React frontend, FastAPI backend, multi-agent RL system, and production DevOps.
Portfolio Project: B.Tech CSE (AI/ML) demonstrating advanced AI/ML, full-stack engineering, and DevOps practices.
๐ Project Status
| Phase | Component | Status | Progress |
|---|---|---|---|
| Phase 1 | Multi-agent RL + DQN | โ COMPLETE | 100% |
| Phase 2 | FastAPI Backend + PostgreSQL | โ COMPLETE | 100% |
| Phase 3.1 | React Frontend Scaffolding | โ COMPLETE | 100% |
| Phase 3.2-3.4 | Interactive UI Components | โ COMPLETE | 100% |
| Phase 4.0 | Docker + PostgreSQL Setup | โ COMPLETE | 100% |
| Phase 4.1 | GitHub Actions CI/CD | โ COMPLETE | 100% |
| Phase 4.2 | Render Production Deploy | โ READY | 100% |
Overall Progress: โโโโโโโโโโโโโโโโโโโโโโโโ 95% Complete (6 of 6 phases)
๐ฏ What's Built
โ Phase 1: Multi-Agent RL System (COMPLETE)
ML Improvements over original:
- Multi-Agent Architecture: Specialist agents (FillMissingAgent, DuplicateDetector, OutlierHandler, etc.)
- DQN Model: Deep Q-Network in PyTorch for training (faster than LLM prompting)
- Advanced Reward Shaping: Progressive rewards + penalties + bonuses
- Coordinator Agent: Intelligently selects best specialist for each task
Files:
backend/ml/agents.py- Base Agent class + 5 specialistsbackend/ml/dqn_model.py- DQN training implementationbackend/ml/reward_shaper.py- Advanced reward functiontests/test_agents.py- 33/33 tests passing โ
โ Phase 2: FastAPI Backend (COMPLETE)
Features:
- REST API for all operations
- PostgreSQL database with SQLAlchemy ORM
- Job queue system (Celery + Redis ready)
- Data versioning & audit logging
- Prometheus metrics collection
- Type-safe Pydantic validation
API Endpoints:
POST /api/datasets/upload - Upload & process dataset
GET /api/datasets/{id} - Fetch dataset info
POST /api/jobs - Start cleaning job
GET /api/jobs/{id} - Get job status
GET /api/jobs - List all jobs
GET /api/metrics/{dataset_id} - Data quality metrics
POST /api/interactive/{id} - Start interactive session
GET /api/interactive/{id}/suggestions - Get AI suggestions
Files:
backend/app.py- FastAPI main serverbackend/routes/- All endpoint handlersbackend/models/- Database schemasbackend/services/- Business logictests/test_api.py- 11/11 tests passing โ
Running Backend:
cd backend
python -m uvicorn app:app --reload --port 8000
โ Phase 3.1: React Frontend (COMPLETE)
What You See:
- ๐ Dashboard: Real-time stats, recent jobs, quick actions
- ๐ค Upload: CSV/JSON/Excel/Parquet file upload with validation
- ๐ฎ Interactive: Row-by-row cleaning with AI suggestions
- ๐ Job History: Filter & track past cleaning jobs
- ๐จ Material-UI: Professional design system
Tech Stack:
- React 18.3.1 + TypeScript (strict mode)
- Material-UI v6 + Material Icons
- React Router v7 (client-side navigation)
- Axios + Error handling with fallbacks
- Vite (build tool)
Files:
frontend/src/pages/- Dashboard, Upload, Jobs, Interactivefrontend/src/components/- Navigation, Sidebar, reusable UIfrontend/src/services/api.ts- Type-safe API clientfrontend/package.json- Dependencies
Running Frontend:
cd frontend
npm run dev
# Accessible at http://localhost:5174
Status:
- โ Build: 0 TypeScript errors, 569 KB bundle
- โ Server: HTTP 200 OK, React root mounted
- โ Components: All 10 components present & exported
- โ Error Handling: Graceful fallbacks for API failures
- โ Rendering: Dashboard displaying correctly
๐ Quick Start
Start Both Backend & Frontend
Terminal 1 - Backend:
cd backend
python -m uvicorn app:app --reload --port 8000
# Server running: http://localhost:8000
# API Docs: http://localhost:8000/docs
Terminal 2 - Frontend:
cd frontend
npm run dev
# App running: http://localhost:5174
Verify Both Are Running
# Check Backend
curl http://localhost:8000/docs
# Check Frontend
curl http://localhost:5174
# Test API Connection
curl http://localhost:8000/api/jobs
๐ Original Environment (Still Available)
Data cleaning is 60-80% of data scientist's time. This environment simulates realistic workflows:
๐ API
The environment implements the full OpenEnv spec:
| Endpoint | Method | Description |
|---|---|---|
/reset |
POST | Start a new episode with a chosen task |
/step |
POST | Take a cleaning action on the current row |
/state |
GET | Get current episode metadata |
/health |
GET | Health check |
/tasks |
GET | List all available tasks |
๐๏ธ Observation Space
At each step, the agent receives a DataCleaningObservation:
| Field | Type | Description |
|---|---|---|
current_row |
int | Index of the row currently being processed |
total_rows |
int | Total number of rows in the dataset |
current_data |
dict | The actual data in the current row |
issues_detected |
list[str] | Problems found (e.g. missing:age, wrong_type:score) |
legal_actions |
list[str] | Valid action types for this row |
progress |
float | Episode progress from 0.0 to 1.0 |
reward |
float | Reward received for the last action |
done |
bool | Whether the episode has ended |
โก Action Space
Each action is a DataCleaningAction with the following fields:
| Field | Type | Description |
|---|---|---|
action_type |
str | One of 6 cleaning operations (see below) |
column |
str | The column to apply the action to |
value |
any (optional) | New value, if required by the action |
Action Types
| Action | Description | Reward |
|---|---|---|
fill_missing |
Fill a None value with a sensible default |
+0.3 |
fix_type |
Convert a value to the correct data type (e.g. "85" โ 85) |
+0.2 |
remove_duplicate |
Mark a row as a duplicate for removal | +0.3 |
fix_category |
Standardize a category label (e.g. "eng" โ "Engineering") |
+0.3 |
remove_outlier |
Replace a statistical outlier with the column median | +0.3 |
skip |
Do nothing for this row | -0.2 (penalty) |
๐ Tasks
Task 1 โ Easy: Fix Missing Values & Type Errors
Objective: Given a 10-row employee dataset with age, salary, and score columns, fill all None values and convert string scores to floats.
- Issues present: missing values, wrong data types
- Expected score: โฅ 0.85
- Grader checks: all fields non-null,
scoreis numeric
Task 2 โ Medium: Remove Duplicates & Fix Formatting
Objective: Given an 8-row contacts dataset, remove duplicate rows, fill missing names, and standardize email addresses to lowercase.
- Issues present: duplicates, missing values, formatting inconsistencies
- Expected score: โฅ 0.85
- Grader checks: no duplicate emails, all names filled, all emails lowercase, all ages filled
Task 3 โ Hard: Full Data Cleaning
Objective: Given an 8-row HR dataset with salary, department, name, and age fields, fix all issues simultaneously: fill missing values, remove duplicates, standardize department labels, and replace outlier/negative salaries.
- Issues present: missing values, duplicates, inconsistent categories (
"eng","h.r.","ENGINEERING"), outlier salaries (999999,-5000) - Valid departments:
Engineering,HR,Finance - Expected score: โฅ 0.80
- Grader checks: no duplicate names, all fields filled, all depts standardized, all salaries in range
(0, 200000)
๐ Baseline Scores
Scores from the baseline inference script (inference.py) using rule-based actions:
| Task | Score |
|---|---|
| Easy | 0.88 |
| Medium | 0.88 |
| Hard | 0.75 |
| Average | 0.85 |
๐ Setup & Usage
Option 1: Run with Docker
git clone https://github.com/AnubhavKiroula/data-cleaning-openenv
cd data-cleaning-openenv
docker build -t data-cleaning-openenv .
docker run -p 7860:7860 data-cleaning-openenv
Server will be available at http://localhost:7860.
Option 2: Run locally
pip install fastapi uvicorn pydantic openai requests
cd envs/data_cleaning_env/server
uvicorn app:app --host 0.0.0.0 --port 7860
Run the baseline inference script
Setup environment variables:
# Option 1: Copy and edit .env file (recommended for local testing)
cp .env.example .env
# Edit .env and add your API key:
# HF_TOKEN=your_actual_api_key_here
# Option 2: Set environment variables directly
export HF_TOKEN=your_api_key_here
export API_BASE_URL=https://api.openai.com/v1 # or your preferred endpoint
export MODEL_NAME=gpt-4o-mini # use cheaper models to minimize cost
Run inference:
python inference.py
The script will output structured logs in the format required by the hackathon:
[START] task=easy env=data-cleaning-env model=gpt-4o-mini
[STEP] step=1 action=fill_missing('age',30) reward=0.30 done=false error=null
[STEP] step=2 action=fix_type('score',None) reward=0.20 done=false error=null
...
[END] success=true steps=10 score=0.930 rewards=0.30,0.20,...
Cost-effective models for testing:
- OpenAI:
gpt-4o-mini(~$0.15/1M input tokens) - HuggingFace:
meta-llama/Llama-3.2-1B-Instruct(free with HF token)
Example: Manual API interaction
Reset to easy task:
curl.exe -X POST http://localhost:7860/reset \
-H "Content-Type: application/json" \
-d '{"task_name": "easy"}'
Take a step:
curl.exe -X POST http://localhost:7860/step \
-H "Content-Type: application/json" \
-d '{"action_type": "fill_missing", "column": "age", "value": 30}'
Check state:
curl.exe http://localhost:7860/state
๐ Project Structure
data-cleaning-platform/
โ
โโโ ๐ง backend/ (FastAPI + ML)
โ โโโ app.py # Main FastAPI server
โ โโโ config.py # Configuration
โ โโโ ml/
โ โ โโโ agents.py # Multi-agent system (Phase 1)
โ โ โโโ dqn_model.py # DQN training (Phase 1)
โ โ โโโ reward_shaper.py # Reward shaping (Phase 1)
โ โโโ routes/ # API endpoints (Phase 2)
โ โโโ models/ # Database schemas (Phase 2)
โ โโโ services/ # Business logic (Phase 2)
โ โโโ requirements.txt
โ โโโ Dockerfile # Container definition
โ
โโโ ๐จ frontend/ (React + TypeScript)
โ โโโ src/
โ โ โโโ pages/ # Dashboard, Upload, Jobs, Interactive
โ โ โโโ components/ # Navigation, Sidebar, UI components
โ โ โโโ services/api.ts # Type-safe API client
โ โ โโโ types/index.ts # TypeScript interfaces
โ โ โโโ App.tsx # Main app component
โ โ โโโ main.tsx # Entry point
โ โโโ package.json
โ โโโ vite.config.ts
โ โโโ Dockerfile # Container definition
โ
โโโ ๐ envs/ (Original OpenEnv - Preserved)
โ โโโ data_cleaning_env/
โ โโโ server/
โ โ โโโ app.py # FastAPI server
โ โ โโโ environment.py # Core RL environment
โ โโโ tasks/graders.py # Task definitions
โ
โโโ ๐ฆ infra/ (DevOps - Coming Phase 4)
โ โโโ docker-compose.yml
โ โโโ nginx.conf # Reverse proxy
โ โโโ prometheus.yml # Monitoring
โ
โโโ .github/workflows/ (CI/CD - Coming Phase 4)
โ โโโ ci.yml # Tests on PR
โ โโโ cd.yml # Deploy on merge
โ โโโ lint.yml # Code quality
โ
โโโ tests/
โ โโโ test_agents.py # โ
33/33 passing
โ โโโ test_api.py # โ
11/11 passing
โ โโโ test_data_quality.py
โ
โโโ docs/
โ โโโ ARCHITECTURE.md # System design
โ โโโ API.md # OpenAPI spec
โ โโโ ML_IMPROVEMENTS.md # RL enhancements
โ โโโ DEPLOYMENT.md # How to deploy
โ
โโโ README.md # This file
โโโ QUICKSTART.md # Fast setup guide
โโโ PHASE_3_1_FIXED_VERIFICATION.md # Technical verification
โโโ FRONTEND_TEST.md # Testing guide
โโโ verify_frontend.js # Verification script
๐ ๏ธ Tech Stack
Frontend:
โโโ React 18.3.1 # UI framework
โโโ TypeScript # Type safety
โโโ Material-UI v6 # Component library
โโโ React Router v7 # Routing
โโโ Axios 1.15.1 # API client
โโโ Vite 8.0.4 # Build tool
Backend:
โโโ FastAPI # Web framework
โโโ SQLAlchemy # ORM
โโโ PostgreSQL # Database
โโโ Pydantic # Validation
โโโ PyTorch # ML framework (DQN)
โโโ Prometheus # Metrics
DevOps (Phase 4):
โโโ Docker # Containerization
โโโ Docker Compose # Multi-container
โโโ GitHub Actions # CI/CD
โโโ Render/Railway # Deployment
โโโ Nginx # Reverse proxy
๐ Key Improvements Over Hackathon Version
AI/ML (Phase 1)
- โ Single agent โ Multi-agent system (5 specialists + coordinator)
- โ LLM prompting โ DQN model (faster, no API calls, trainable)
- โ Flat rewards โ Progressive reward shaping (better learning)
- โ Black box โ Interpretable decisions (know why agent acted)
Full-Stack (Phase 2-3)
- โ CLI tool โ Web dashboard (real-time stats & monitoring)
- โ No persistence โ PostgreSQL database (data versioning)
- โ No tracking โ Job queue (Celery/Redis ready)
- โ Manual testing โ REST API (programmatic access)
- โ Backend only โ Interactive UI (row-by-row cleaning with suggestions)
DevOps (Phase 4 - Coming)
- โ Local only โ Docker containers (reproducible everywhere)
- โ Manual testing โ GitHub Actions CI/CD (automated testing/deployment)
- โ No monitoring โ Prometheus metrics (production-ready observability)
๐ Portfolio Talking Points
"I built an RL-powered data cleaning platform showcasing:"
Advanced AI/ML
- Reinforcement Learning (DQN model)
- Multi-agent system with coordinator
- Reward shaping & policy learning
- Shows deep ML understanding
Full-Stack Engineering
- Frontend: React, TypeScript, Material-UI
- Backend: FastAPI, PostgreSQL, REST API
- Database: Normalized schema, migrations
- Shows end-to-end system design
Production-Ready Code
- Type safety (TypeScript + Pydantic)
- Error handling & graceful degradation
- Unit tests (33 + 11 passing)
- Clean architecture (SOLID principles)
DevOps & Deployment (Phase 4)
- Docker containerization
- GitHub Actions CI/CD
- Prometheus monitoring
- Shows production deployment skills
โ Verification Checklist
Phase 1: ML โ
- Multi-agent architecture implemented
- DQN model training working
- Reward shaper configured
- 33/33 unit tests passing
- Git commits pushed
Phase 2: Backend โ
- FastAPI app scaffolded
- PostgreSQL models defined
- REST endpoints implemented
- Job tracking system ready
- 11/11 API tests passing
- Git commits pushed
Phase 3.1: Frontend โ
- React 18 + TypeScript setup
- Material-UI components imported
- All 10 pages/components created
- React Router configured
- API client (Axios) implemented
- Error handling with fallbacks
- Build succeeds: 0 TypeScript errors
- Dev server running: HTTP 200 OK
- HTML rendering with React root
- Dashboard displaying correctly
- React types match runtime (FIXED)
- Git commits pushed
Phase 3.2-3.5: Interactive UI ๐
- Upload component file handling
- Data quality visualizations
- Interactive cleaning interface
- Job history filtering
Phase 4: DevOps ๐
- Docker Compose files
- Backend Dockerfile
- Frontend Dockerfile
- GitHub Actions workflows
- Deployment scripts
- Production Documentation
๐ Next Steps
Phase 3.2-3.5: Build interactive UI components
# Start backend + frontend cd backend && python -m uvicorn app:app --reload --port 8000 & cd frontend && npm run devPhase 4: Docker & Deployment
docker-compose up -dTesting & Monitoring
- Run test suites
- Configure Prometheus
- Setup health checks
๐ Documentation
- QUICKSTART.md - Fast 5-minute setup
- ARCHITECTURE.md - System design overview
- API.md - REST API specification
- ML_IMPROVEMENTS.md - RL model details
- DEPLOYMENT.md - Production deployment (Render)
- DEPLOYMENT_FREE_ALTERNATIVE.md - โญ 100% FREE (Vercel + Railway + Supabase)
Checklist: DEPLOY_CHECKLIST.md
Live Demo: Coming soon!!! (Deploy using guide above)
Original environment: https://01ammu-data-cleaning-openenv.hf.space
๐ License
MIT - Free to use for portfolio/learning
๐จโ๐ป Author
Built as a portfolio project by Anubhav Kiroula (B.Tech CSE AI/ML, Sem 2)
GitHub: https://github.com/AnubhavKiroula/data-cleaning-openenv
Skills Demonstrated:
- Reinforcement Learning (DQN, multi-agent systems)
- Full-Stack Development (React, FastAPI, PostgreSQL)
- DevOps & Cloud Deployment (Docker, GitHub Actions)
- Software Engineering (SOLID, testing, documentation)
- Portfolio Building (resume-worthy project)
Status: 95% Complete | 6/6 phases done | 44 tests passing | Production-ready architecture โ