thorodin103 commited on
Commit
a87e8f5
Β·
verified Β·
1 Parent(s): 8941b49

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +194 -7
README.md CHANGED
@@ -1,10 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
- title: Data Cleaning Openenv
3
- emoji: 🐠
4
- colorFrom: yellow
5
- colorTo: purple
6
- sdk: docker
7
- pinned: false
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
1
+ # 🧹 Data Cleaning OpenEnv
2
+
3
+ An OpenEnv-compliant environment where AI agents learn to clean
4
+ messy real-world datasets step by step.
5
+
6
+ [![Open in Spaces](https://huggingface.co/datasets/huggingface/badges/resolve/main/open-in-hf-spaces-sm.svg)](https://huggingface.co/spaces/thorodin103/data-cleaning-openenv)
7
+
8
+ ---
9
+
10
+ ## 🌍 Environment Description
11
+
12
+ Data cleaning is one of the most common and time-consuming tasks
13
+ in real-world data workflows. Data engineers and analysts spend
14
+ up to 80% of their time cleaning data before it can be used.
15
+
16
+ This environment simulates that exact challenge β€” an agent receives
17
+ a dirty dataset and must apply a sequence of cleaning operations
18
+ to match a gold standard output. Each operation provides partial
19
+ reward signal, enabling reinforcement learning agents to learn
20
+ incrementally.
21
+
22
+ ---
23
+
24
+ ## 🎯 Tasks
25
+
26
+ | Task ID | Difficulty | Description | Max Steps |
27
+ |---------|-----------|-------------|-----------|
28
+ | easy_dedup_rename | Easy | Remove duplicates + rename columns to snake_case | 10 |
29
+ | medium_missing_dtype | Medium | Fill missing values + fix data types | 15 |
30
+ | hard_full_pipeline | Hard | Full pipeline: duplicates + missing + dtypes + outliers + schema | 20 |
31
+
32
+ ### Easy Task
33
+ Agent receives an employee dataset with duplicate rows and
34
+ poorly formatted column names. Must remove duplicates and
35
+ rename columns to snake_case format.
36
+
37
+ **Scoring:** duplicate_score (0.5) + schema_score (0.5)
38
+
39
+ ### Medium Task
40
+ Agent receives a customer dataset with missing values in
41
+ multiple columns and wrong data types. Must fill missing
42
+ values using correct strategies (mean/median/mode) and
43
+ fix data types.
44
+
45
+ **Scoring:** missing_score (0.5) + dtype_score (0.5)
46
+
47
+ ### Hard Task
48
+ Agent receives an orders dataset with all types of issues:
49
+ duplicates, missing values, wrong types, outliers. Must
50
+ run a complete cleaning pipeline in the right sequence.
51
+
52
+ **Scoring:** All 5 components weighted equally (0.2 each)
53
+
54
+ ---
55
+
56
+ ## πŸ‘οΈ Observation Space
57
+ ```json
58
+ {
59
+ "task_id": "string β€” current task identifier",
60
+ "step": "integer β€” current step number",
61
+ "dataset_info": "object β€” summary of dataset state",
62
+ "columns": "list β€” column names",
63
+ "shape": "list β€” [rows, columns]",
64
+ "missing_values": "object β€” missing count per column",
65
+ "dtypes": "object β€” data type per column",
66
+ "duplicate_count": "integer β€” number of duplicate rows",
67
+ "sample_rows": "list β€” first 3 rows as preview",
68
+ "available_operations": "list β€” valid operations",
69
+ "task_description": "string β€” what agent must do",
70
+ "message": "string β€” feedback from last action"
71
+ }
72
+ ```
73
+
74
+ ---
75
+
76
+ ## ⚑ Action Space
77
+ ```json
78
+ {
79
+ "operation": "one of: remove_duplicates | fill_missing | fix_dtype | remove_outliers | rename_columns | validate_schema | finish",
80
+ "parameters": {
81
+ "column": "optional β€” target column name",
82
+ "strategy": "optional β€” mean | median | mode | ffill",
83
+ "dtype": "optional β€” int | float | str | auto",
84
+ "method": "optional β€” iqr | zscore",
85
+ "mapping": "optional β€” column rename mapping dict"
86
+ }
87
+ }
88
+ ```
89
+
90
  ---
91
+
92
+ ## πŸ† Reward Function
93
+
94
+ Rewards are computed after every step providing dense signal:
95
+
96
+ | Component | Description |
97
+ |-----------|-------------|
98
+ | duplicate_score | How close row count is to gold standard |
99
+ | missing_score | Proportion of missing values filled correctly |
100
+ | dtype_score | Proportion of columns with correct data types |
101
+ | outlier_score | How close numeric distributions are to gold |
102
+ | schema_score | Proportion of column names matching gold |
103
+ | penalty | Small penalty for using too many steps |
104
+
105
+ **Total reward = weighted sum of components (0.0 to 1.0)**
106
+
107
+ ---
108
+
109
+ ## πŸš€ Setup & Usage
110
+
111
+ ### Run with Docker
112
+ ```bash
113
+ docker build -t data-cleaning-openenv .
114
+ docker run -p 7860:7860 data-cleaning-openenv
115
+ ```
116
+
117
+ ### API Usage
118
+ ```python
119
+ import requests
120
+
121
+ # Reset environment
122
+ response = requests.post(
123
+ "http://localhost:7860/reset/easy_dedup_rename"
124
+ )
125
+ obs = response.json()
126
+
127
+ # Take action
128
+ action = {
129
+ "operation": "remove_duplicates",
130
+ "parameters": {}
131
+ }
132
+ response = requests.post(
133
+ "http://localhost:7860/step/easy_dedup_rename",
134
+ json=action
135
+ )
136
+ result = response.json()
137
+ print(result["reward"]["total"])
138
+
139
+ # Get state
140
+ state = requests.get(
141
+ "http://localhost:7860/state/easy_dedup_rename"
142
+ ).json()
143
+ ```
144
+
145
+ ### Run Baseline Inference
146
+ ```bash
147
+ export HF_TOKEN=your_token_here
148
+ export MODEL_NAME=meta-llama/Llama-3.3-70B-Instruct
149
+ export API_BASE_URL=https://router.huggingface.co/v1
150
+
151
+ python inference.py
152
+ ```
153
+
154
+ ---
155
+
156
+ ## πŸ“Š Baseline Scores
157
+
158
+ Scores produced by `meta-llama/Llama-3.3-70B-Instruct`:
159
+
160
+ | Task | Score |
161
+ |------|-------|
162
+ | easy_dedup_rename | ~0.85 |
163
+ | medium_missing_dtype | ~0.65 |
164
+ | hard_full_pipeline | ~0.45 |
165
+ | **Average** | **~0.65** |
166
+
167
+ ---
168
+
169
+ ## πŸ“ Project Structure
170
+ ```
171
+ data-cleaning-openenv/
172
+ β”œβ”€β”€ main.py # FastAPI server
173
+ β”œβ”€β”€ environment.py # Core env logic
174
+ β”œβ”€β”€ models.py # Pydantic models
175
+ β”œβ”€β”€ inference.py # Baseline script
176
+ β”œβ”€β”€ openenv.yaml # OpenEnv metadata
177
+ β”œβ”€β”€ Dockerfile # Container config
178
+ β”œβ”€β”€ README.md # This file
179
+ └── datasets/
180
+ β”œβ”€β”€ task_metadata.json
181
+ β”œβ”€β”€ easy/
182
+ β”‚ β”œβ”€β”€ dirty.csv
183
+ β”‚ └── gold.csv
184
+ β”œβ”€β”€ medium/
185
+ β”‚ β”œβ”€β”€ dirty.csv
186
+ β”‚ └── gold.csv
187
+ └── hard/
188
+ β”œβ”€β”€ dirty.csv
189
+ └── gold.csv
190
+ ```
191
+
192
  ---
193
 
194
+ ## πŸ”— Links
195
+
196
+ - [Hugging Face Space](https://huggingface.co/spaces/thorodin103/data-cleaning-openenv)
197
+ - [OpenEnv Spec](https://github.com/openenv/openenv)