Spaces:
Sleeping
Sleeping
File size: 2,532 Bytes
1be0df2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | from __future__ import annotations
from typing import Any, Dict, List, Literal, Optional
from pydantic import BaseModel
# ββ Action ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
class CleaningAction(BaseModel):
"""One data-cleaning operation the agent wants to apply."""
operation: Literal[
"fill_nulls", # fill missing values in a column
"drop_duplicates", # remove duplicate rows
"fix_type", # cast a column to the correct dtype
"normalise_column", # standardise inconsistent category labels
"drop_column", # remove an irrelevant/corrupted column
"fix_date_format", # parse & unify mixed date strings
"clip_outliers", # winsorise extreme numeric values
"rename_column", # fix a misnamed column header
"submit", # agent declares it is done
]
column: Optional[str] = None # target column (None for row-wise ops)
params: Dict[str, Any] = {} # operation-specific parameters
reasoning: str = "" # agent explains its action (scored)
# ββ Observation βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
class ColumnSummary(BaseModel):
name: str
dtype: str
null_count: int
unique_count: int
sample_values: List[Any] # up to 5 representative values
class CleaningObservation(BaseModel):
task_id: str # "easy" | "medium" | "hard"
step: int
done: bool
reward: Optional[float]
shape: List[int] # [rows, cols]
columns: List[ColumnSummary]
issues_detected: List[str] # human-readable problem list
data_quality_score: float # 0.0β1.0, updated every step
message: str # feedback on last action
# ββ State βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
class CleaningState(BaseModel):
episode_id: Optional[str] = None
task_id: str = "easy"
step_count: int = 0
max_steps: int = 20
cumulative_reward: float = 0.0
actions_taken: List[str] = []
|