DevKaushal/DataQualityEnv
DataQualityEnv ๐งน
A production-ready OpenEnv RL environment for training AI agents to audit and fix messy datasets.
1. Environment Description & Motivation
Real-world data pipelines are routinely polluted with missing values, duplicate records, wrong data types, statistical outliers, and inconsistent formats. Data teams spend a disproportionate amount of time on these repetitive auditing tasks.
DataQualityEnv turns data cleaning into a structured RL problem:
- An agent receives a partially corrupted synthetic dataset.
- It inspects the dataset via a rich
Observationincluding per-column statistics and a dataset preview. - It applies structured
Actions(fill missing, drop duplicates, fix dtypes, etc.) one at a time. - It receives a reward signal proportional to the overall data quality score it achieves.
- The episode ends when the dataset reaches a passing quality threshold, the agent signals
done, or it exhausts its step budget.
This framing is directly applicable to AutoML pipelines, data lake governance tools, and ETL automation.
2. Action Space
All actions accept an optional column field and an arbitrary params dict for future extensibility.
3. Observation Space
4. Task Descriptions
Datasets:
null_hunterโ 100 rows ร 5 columns, 10 % nullsfull_cleanupโ 200 rows ร 7 columns, nulls + 15 % duplicates + 2 wrong-dtype columnsmaster_auditโ 300 rows ร 10 columns, all of the above + 3-sigma outliers + mixed date formats
5. Reward Function
reward = quality_score(df, task_id) # absolute quality, 0.0โ1.0
โ 0.05 if quality_delta โค 0 # penalise no-progress steps
โ 0.02 if action is a no-op # penalise wasted actionsThe quality score is a weighted average across four dimensions:
The task graders apply task-specific weightings on top of this global score, adding a date-format compliance term for master_audit.
Reward is always clamped to [0.0, 1.0].
6. Setup & Usage
Prerequisites
- Docker โฅ 20 or Python 3.11+
Docker (recommended)
# Build
docker build -t data-quality-env .
# Run server (port 7860)
docker run -p 7860:7860 data-quality-envLocal (without Docker)
pip install -r requirements.txt
uvicorn app.main:app --host 0.0.0.0 --port 7860API Examples
Health check
curl http://localhost:7860/health
# {"status":"ok"}List tasks
curl http://localhost:7860/tasksReset environment
curl -X POST http://localhost:7860/reset \
-H "Content-Type: application/json" \
-d '{"task_id": "null_hunter"}'Take a step
curl -X POST http://localhost:7860/step \
-H "Content-Type: application/json" \
-d '{"action_type": "fill_missing", "column": null, "params": {}}'Inspect current state
curl http://localhost:7860/stateRunning inference.py
Set the required environment variables, then:
export API_BASE_URL="http://localhost:7860" # DataQualityEnv server
export MODEL_NAME="mistralai/Mistral-7B-Instruct-v0.3"
export HF_TOKEN="hf_..."
python inference.py7. Baseline Scores
These scores represent a rule-based greedy agent that always applies the most impactful action first.
8. Environment Variables
โ ๏ธ Never hard-code credentials. All secrets must be injected via environment variables.
Project Structure
DataQualityEnv/
โโโ app/
โ โโโ __init__.py
โ โโโ main.py โ FastAPI app (port 7860)
โ โโโ models.py โ Pydantic v2 models
โ โโโ environment.py โ Core RL environment logic
โ โโโ tasks.py โ Task definitions and graders
โ โโโ datasets.py โ Synthetic dataset generator
โโโ inference.py โ LLM agent runner (root level)
โโโ openenv.yaml โ OpenEnv manifest
โโโ Dockerfile
โโโ requirements.txt
โโโ README.mdLicense
MIT
