ardurai/god-skill-suite/god-data-cleaning

Claude Code and agent skill by ardurai/god-skill-suite

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

God-level data cleaning, preprocessing, and feature engineering skill. Covers the full data preparation pipeline: missing value strategies, outlier detection and treatment, data type coercion, duplicate detection, text normalization, categorical encoding, numerical scaling, imbalanced dataset handling, time series preprocessing, data validation with Great Expectations and Pandera, feature engineering from domain knowledge, automated feature engineering (Featuretools), data versioning (DVC), and the researcher-warrior truth: garbage in = garbage out, and most ML failures are data failures not model failures. Covers Pandas, Polars, NumPy, scikit-learn preprocessing, and PySpark for scale.

Install

npx vskill@latest install ardurai/god-skill-suite/god-data-cleaning

SKILL.md

The same SKILL.md was published earlier as ardurai/god-skill-suite/god-data-cleaning.

God-Level Data Cleaning & Feature Engineering

Researcher-Warrior Mindset

You are not a notebook jockey. You are a data warrior who understands that every assumption about a dataset is a potential bug in production. You verify everything. You trust nothing until you have inspected it. You know that the model is the last 20% of the work — the first 80% is data.

Anti-hallucination mandate: Never assert that a dataset is clean without running validation. Never assume an encoding, a date format, or a timezone. Never impute without understanding WHY data is missing. Always verify library API signatures against the installed version — sklearn, pandas, and polars all break APIs between major versions.

Cross-domain mandate: Apply lessons from bioinformatics (missing genotype data is MNAR), finance (zero volume means market closed, not zero volume), NLP (token frequency follows power law), and systems engineering (sensor dropout patterns encode system state) — data patterns from other domains often apply to your current problem.


The Data Quality Manifesto

80% of ML work is data work. This is not a figure of speech — it is the measured reality from every serious ML deployment. A model trained on bad data learns to replicate the errors in that data with high confidence. A sophisticated model on corrupted data is more dangerous than a simple model on clean data, because it produces wrong answers with high confidence.

Axioms every data practitioner must internalize:

  1. A model is only as good as its data. Period. No architecture choice compensates for systematic bias in labels.
  2. Never skip exploratory data analysis (EDA). You will find things that invalidate your assumptions every single time.
  3. Data leakage is the most common reason ML systems work in development and fail in production. It almost always originates in data preparation, not modeling.
  4. Distribution shift is a data problem, not a model problem. Monitor your input distributions in production with the same rigor you monitor model outputs.
  5. Reproducibility starts at the data level. A model trained on an undocumented dataset version is not reproducible.
  6. Garbage in = garbage out. No exception. Ever.
  7. Most ML "model failures" in production are actually data pipeline failures: schema drift, upstream system changes, silent data corruption.

The cost of skipping data analysis: In 2012, a major financial institution deployed a credit risk model that performed brilliantly in backtesting. It collapsed within 3 months of deployment. Root cause: a single boolean column had its encoding convention reversed by an upstream ETL change. No validation suite caught it because there was no validation suite. The model's AUC dropped from 0.82 to 0.51 — worse than random on the affected segment. This is not a horror story. This is Tuesday.


Missing Data Taxonomy — Why the Type Determines the Strategy

Understanding WHY data is missing is not academic — it determines which imputation strategies are statistically valid.

MCAR — Missing Completely At Random

The probability of being missing is the same for all observations. Missingness is independent of both the observed and unobserved data. Example: a random system error drops 2% of sensor readings with no pattern.

Test: Little's MCAR test (in pyampute or R's mice package). Strategy: Simple deletion is valid if the missing fraction is small (< 5%). Any imputation method is also valid since missingness is truly random.

MAR — Missing At Random

The probability of being missing depends on observed data, but not on the unobserved values themselves. Example: women are less likely to report income (missingness depends on gender, which is observed), but given gender, missingness is random with respect to the income value itself.

Test: No definitive statistical test. Analyze missingness correlation with other features. Strategy: Multiple imputation (MICE) is the gold standard. Model-based imputation conditioned on correlated features is valid.

MNAR — Missing Not At Random

The most dangerous type. The probability of being missing depends on the value itself. Example: people with very high or very low incomes are less likely to report income. Patients who are very sick are more likely to miss follow-up appointments. Sensors fail more often at extreme temperatures — the failure itself encodes information.

Test: No definitive test from data alone — requires domain knowledge. Strategy: You cannot impute MNAR data without making strong assumptions. Options: (1) model the missingness mechanism explicitly, (2) use pattern mixture models, (3) include a binary indicator for missingness as a feature (always do this for MNAR), (4) collect more data that explains the missingness. Never use mean/median imputation for MNAR — you are systematically biasing your analysis.


Missing Value Strategies

1. Deletion
python
# Listwise deletion — only valid for MCAR, small fraction
df.dropna(subset=['critical_column']) # Drop rows with missing in specific column
df.dropna(thresh=df.shape[1] * 0.8) # Keep rows with at least 80% non-null
# Column deletion — if a feature is >60% missing and MNAR, often the right call
missing_pct = df.isnull().mean()
df.drop(columns=missing_pct[missing_pct > 0.6].index, inplace=True)

When: MCAR, missing fraction < 5% for listwise. Column deletion when feature is mostly missing and unlikely to be imputable without introducing major bias.

2. Mean/Median/Mode Imputation
python
from sklearn.impute import SimpleImputer
import pandas as pd
# Mean — only for normally distributed numeric, MCAR/MAR only
num_imputer = SimpleImputer(strategy='mean')
# Median — preferred for skewed distributions (more robust to outliers)
num_imputer = SimpleImputer(strategy='median')
# Most frequent — for categorical
cat_imputer = SimpleImputer(strategy='most_frequent')
# Constant — when domain knowledge specifies a fill value
const_imputer = SimpleImputer(strategy='constant', fill_value=0)

When: MCAR/MAR, numeric with roughly symmetric distribution (for mean), categorical (for mode). Never for MNAR — destroys the signal encoded in the missingness pattern.

3. KNN Imputation
python
from sklearn.impute import KNNImputer
imputer = KNNImputer(n_neighbors=5, weights='uniform')
# weights='distance' gives closer neighbors more weight — usually better
df_imputed = pd.DataFrame(
imputer.fit_transform(df[numeric_cols]),
columns=numeric_cols
)

When: MAR, features have meaningful similarity structure, dataset is not too large (KNN is O(n) per query). KNN imputation respects local data structure. Verify: Fit on training data ONLY, transform train and test separately — this is a common source of data leakage.

4. Iterative Imputation (MICE Algorithm)

Multiple Imputation by Chained Equations — the gold standard for MAR data.

python
from sklearn.experimental import enable_iterative_imputer # Required import
from sklearn.impute import IterativeImputer
from sklearn.ensemble import RandomForestRegressor
# Default uses BayesianRidge — faster
imputer = IterativeImputer(max_iter=10, random_state=42)
# RandomForest estimator — more accurate, slower, handles non-linear relationships
imputer = IterativeImputer(
estimator=RandomForestRegressor(n_estimators=10, random_state=42),
max_iter=10,
random_state=42
)
# Fit on training data ONLY
imputer.fit(X_train)
X_train_imputed = imputer.transform(X_train)
X_test_imputed = imputer.transform(X_test)

Mechanism: Iteratively regresses each feature with missing values on all other features. Cycles through all features until convergence. Handles multiple features simultaneously. Warning: enable_iterative_imputer is required as of scikit-learn 1.x — verify with your installed version.

5. Indicator Variable for Missingness

Always add a binary indicator when missingness is informative (MNAR, or MAR with high correlation to outcome).

python
from sklearn.impute import MissingIndicator
indicator = MissingIndicator(features='missing-only')
missing_flags = indicator.fit_transform(df)
missing_flag_df = pd.DataFrame(
missing_flags,
columns=[f'{col}_was_missing' for col in df.columns[indicator.features_]]
)
df_augmented = pd.concat([df, missing_flag_df], axis=1)

Outlier Detection

IQR Method (Non-parametric, robust)
python
Q1 = df['col'].quantile(0.25)
Q3 = df['col'].quantile(0.75)
IQR = Q3 - Q1
lower = Q1 - 1.5 * IQR
upper = Q3 + 1.5 * IQR
outliers = df[(df['col'] < lower) | (df['col'] > upper)]

Use when: No normality assumption, general-purpose. The 1.5x multiplier is Tukey's standard; use 3.0 for "extreme" outliers.

Z-Score Method (Parametric)
python
from scipy import stats
z_scores = np.abs(stats.zscore(df['col'].dropna()))
outliers = df[z_scores > 3]

Use when: Data is approximately normally distributed. Z > 3 captures ~0.3% of normal distribution.

Modified Z-Score (Iglewicz-Hoaglin) — More Robust
python
def modified_zscore(series):
median = series.median()
mad = (series - median).abs().median() # Median Absolute Deviation
return 0.6745 * (series - median) / mad # 0.6745 = 1/Φ^-1(3/4)
scores = modified_zscore(df['col'])
outliers = df[scores.abs() > 3.5] # 3.5 is the Iglewicz-Hoaglin threshold

Use when: Data may have heavy tails, MAD is more robust than standard deviation to outliers in the data being analyzed.

Isolation Forest (Multivariate, model-based)
python
from sklearn.ensemble import IsolationForest
iso = IsolationForest(contamination=0.05, random_state=42)
# contamination = expected fraction of outliers — requires domain knowledge
df['outlier_score'] = iso.fit_predict(df[numeric_features])
# Returns -1 for outliers, 1 for inliers
outliers = df[df['outlier_score'] == -1]

Use when: Multivariate outliers (not detectable in individual dimensions), high-dimensional data. Isolation Forest works by randomly partitioning data — outliers are easier to isolate (require fewer splits).

Local Outlier Factor (Density-based)
python
from sklearn.neighbors import LocalOutlierFactor
lof = LocalOutlierFactor(n_neighbors=20, contamination=0.05)
labels = lof.fit_predict(df[numeric_features])
# LOF does not support predict() after fit — must fit_predict together
outliers = df[labels == -1]

Use when: Clusters of different densities — LOF compares local density to neighbors' density. A point is an outlier if its density is significantly lower than its neighbors'.

Outlier Treatment
python
# 1. Winsorizing (capping) — replace extreme values with percentile boundaries
from scipy.stats.mstats import winsorize
df['col_winsorized'] = winsorize(df['col'], limits=[0.05, 0.05])
# 2. Log transform — compresses right tail, good for income/price/count data
df['col_log'] = np.log1p(df['col']) # log1p handles zeros: log(1+x)
# 3. Separate model — flag outliers with an indicator, model separately
df['is_outlier'] = (iso.fit_predict(df[features]) == -1).astype(int)

Duplicate Detection

Exact Duplicates
python
# Find exact duplicates
duplicates = df.duplicated(keep=False) # Mark all duplicates
df_clean = df.drop_duplicates(keep='first')
# Duplicates on key columns only
duplicates = df.duplicated(subset=['customer_id', 'transaction_date'], keep=False)
Near-Duplicate Detection with MinHash LSH
python
from datasketch import MinHash, MinHashLSH
lsh = MinHashLSH(threshold=0.8, num_perm=128)
minhashes = {}
for idx, text in df['text_column'].items():
m = MinHash(num_perm=128)
for word in text.lower().split():
m.update(word.encode('utf8'))
lsh.insert(str(idx), m)
minhashes[str(idx)] = m

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/ardurai/god-skill-suite/god-data-cleaning/badge)](https://verified-skill.com/skills/ardurai/god-skill-suite/god-data-cleaning)

Something wrong with this skill or its page? Tell us.