CoolFace
Apppublic

VivienB/data-quality-auditing-env

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
App README

๐Ÿ“Š Data Quality Auditing OpenEnv

An interactive, OpenEnv-compliant benchmark environment for evaluating AI agents on data quality auditing tasks.

๐ŸŽฏ Overview

The Data Quality Auditing OpenEnv simulates a real-world data engineering scenario where an AI agent must evaluate datasets, identify quality issues, and generate structured audit reports. The environment follows the standard OpenEnv API (reset, step, state) and provides a robust framework for testing agent capabilities in data analysis, reasoning, and reporting.

Key Features

  • โ€”Standardized API: Fully compliant with OpenEnv standards.
  • โ€”Multi-level Tasks: Datasets categorized into Easy, Medium, and Hard difficulties.
  • โ€”Comprehensive Taxonomy: Supports detection of missing values, duplicates, type mismatches, outliers, inconsistencies, and bias.
  • โ€”Reward System: Built-in rule-based grader that evaluates precision, recall, F1 score, and severity-weighted accuracy.
  • โ€”Baseline Agent: Includes a reproducible OpenAI-powered baseline agent.
  • โ€”Interactive UI: Deployable Gradio application for Hugging Face Spaces.

๐Ÿ—๏ธ Environment Design

Observation Space

The state represents the current view of the dataset and the agent's progress:

  • โ€”dataset_sample: A subset of rows from the dataset.
  • โ€”schema_info: Column names, expected data types, and constraints.
  • โ€”column_stats: Summary statistics for queried columns.
  • โ€”current_report: The ongoing list of identified issues.
  • โ€”steps_remaining: Number of actions the agent can still take.

Action Space

The agent interacts with the environment using discrete actions:

  • โ€”view_schema(): Retrieve the schema of the dataset.
  • โ€”sample_rows(n): View n random rows from the dataset.
  • โ€”query_column(col_name): Get summary statistics or unique values for a specific column.
  • โ€”report_issue(issue_type, column, description, severity): Log an identified issue into the audit report.
  • โ€”submit_audit(): Finalize the audit and terminate the episode.

Reward Structure

The reward incentivizes accurate and comprehensive auditing while penalizing false positives and inefficiency:

  • โ€”+10 for correctly identifying a valid issue (True Positive).
  • โ€”-5 for reporting a non-existent issue (False Positive).
  • โ€”-1 for each action taken (step penalty to encourage efficiency).
  • โ€”+50 bonus for finding all critical issues in the dataset.

๐Ÿš€ Getting Started

Prerequisites

  • โ€”Python 3.11+
  • โ€”OpenAI API Key (for the baseline agent and LLM grader)

Installation

  1. 1.Clone the repository and navigate to the project directory:
bash
   git clone https://github.com/yourusername/data-quality-openenv.git
   cd data-quality-openenv
  1. 1.Install the required dependencies:
bash
   pip install -r requirements.txt
  1. 1.Set your OpenAI API key:
bash
   export OPENAI_API_KEY="your-api-key-here"

๐Ÿค– Running the Baseline Agent

The baseline agent uses the OpenAI API to systematically explore the dataset, analyze the data, and generate an audit report.

Run the agent on a specific task:

bash
python baseline/run_agent.py --task easy_001

Run the agent on a harder task using a specific model:

bash
python baseline/run_agent.py --task hard_001 --model gpt-4.1-mini

Run the agent on all available tasks and save the results:

bash
python baseline/run_agent.py --all --output results.json

๐Ÿงช Evaluation & Grading

The environment includes a robust grading system (grader.py) that evaluates the agent's audit report against the ground truth issues defined in the task files.

The grader calculates:

  • โ€”Precision: The proportion of reported issues that are correct.
  • โ€”Recall: The proportion of ground truth issues that were successfully identified.
  • โ€”F1 Score: The harmonic mean of precision and recall.
  • โ€”Weighted Score: A score based on the severity of the identified issues (Critical=4, High=3, Medium=2, Low=1).
  • โ€”Letter Grade: A final grade (A-F) based on the normalized weighted score.

You can run the grader standalone:

bash
python grader.py --report path/to/report.json --ground-truth path/to/ground_truth.json

๐Ÿ“ฆ Deployment (Hugging Face Spaces)

The project includes a Gradio web application (app.py) that provides an interactive UI for exploring tasks and running the baseline agent.

To run the app locally:

bash
python app.py

Then open your browser to http://localhost:7860.

To deploy via Docker:

bash
docker build -t data-quality-openenv .
docker run -p 7860:7860 data-quality-openenv

๐Ÿ“ Project Structure

data_quality_openenv/
โ”œโ”€โ”€ app.py                  # Gradio UI for Hugging Face Spaces
โ”œโ”€โ”€ baseline/
โ”‚   โ””โ”€โ”€ run_agent.py        # OpenAI-powered baseline agent
โ”œโ”€โ”€ Dockerfile              # Docker configuration for deployment
โ”œโ”€โ”€ env.py                  # Core OpenEnv environment implementation
โ”œโ”€โ”€ grader.py               # Reward and grading system
โ”œโ”€โ”€ models.py               # Pydantic typed data models
โ”œโ”€โ”€ problem_definition.md   # Detailed problem scope and design document
โ”œโ”€โ”€ README.md               # Project documentation
โ”œโ”€โ”€ requirements.txt        # Python dependencies
โ””โ”€โ”€ tasks/                  # Task datasets and ground truth
    โ”œโ”€โ”€ easy.json
    โ”œโ”€โ”€ medium.json
    โ””โ”€โ”€ hard.json

๐Ÿ“ License

This project is licensed under the MIT License. See the LICENSE file for details.