Skip to content

feat: sanitize wide/sparse datasets before clustering#5

Merged
ginaecho merged 1 commit into
mainfrom
feat/Improvement-AutoSkills
Jun 16, 2026
Merged

feat: sanitize wide/sparse datasets before clustering#5
ginaecho merged 1 commit into
mainfrom
feat/Improvement-AutoSkills

Conversation

@ginaecho

Copy link
Copy Markdown
Owner

Wide, sparse feature exports (e.g. 152-col scanner CSV where 66 cols are ~99% null and 55 are constant) stalled the pipeline: NaN/inf crashed the scaler/PCA in feature selection and constant/rank-deficient columns slowed the VIF gate.

  • skills/data_cleaner.py: new pure skill — drop all-null, mostly-null (>max_null_frac), constant, and duplicate columns; median-impute remaining NaN and treat +/-inf as missing.
  • orchestrator: prune low-value columns at load for both the raw-CSV and pre-engineered-parquet paths; emit a data_cleaning event.
  • feature_selector: defensive NaN/inf imputation before scaling; generic high-dim guard (max_features_for_vif) keeps top-N by PCA+AE importance before the VIF gate so cost stays bounded on wide dense matrices.
  • config.yaml: data_cleaning (enabled/max_null_frac/drop_constant) and max_features_for_vif knobs; docs in skill.md + docs/skills/data_cleaner.md.

Wide, sparse feature exports (e.g. 152-col scanner CSV where 66 cols are
~99% null and 55 are constant) stalled the pipeline: NaN/inf crashed the
scaler/PCA in feature selection and constant/rank-deficient columns slowed
the VIF gate.

- skills/data_cleaner.py: new pure skill — drop all-null, mostly-null
  (>max_null_frac), constant, and duplicate columns; median-impute remaining
  NaN and treat +/-inf as missing.
- orchestrator: prune low-value columns at load for both the raw-CSV and
  pre-engineered-parquet paths; emit a data_cleaning event.
- feature_selector: defensive NaN/inf imputation before scaling; generic
  high-dim guard (max_features_for_vif) keeps top-N by PCA+AE importance
  before the VIF gate so cost stays bounded on wide dense matrices.
- config.yaml: data_cleaning (enabled/max_null_frac/drop_constant) and
  max_features_for_vif knobs; docs in skill.md + docs/skills/data_cleaner.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 16, 2026 07:45
@ginaecho ginaecho merged commit 79d0b69 into main Jun 16, 2026
@ginaecho ginaecho deleted the feat/Improvement-AutoSkills branch June 16, 2026 07:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a deterministic data-cleaning skill and wires it into the pipeline to prevent wide/sparse datasets (NaN/inf, all-null/mostly-null/constant columns) from stalling or crashing downstream feature selection (scaling/PCA/AE/VIF), plus a runtime guard to bound VIF cost on high-dimensional dense matrices.

Changes:

  • Introduces skills/data_cleaner.py with column-pruning and numeric imputation utilities, plus docs.
  • Applies load-time column pruning in Orchestrator for both raw-CSV and pre-engineered-parquet inputs and emits a data_cleaning event.
  • Adds defensive NaN/inf handling in FeatureSelectionAgent and a max_features_for_vif prefilter to cap VIF runtime.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
skills/data_cleaner.py New skill implementing column pruning + optional numeric imputation with reporting.
skills/init.py Exposes the new data cleaner functions via the skills package API.
skill.md Documents the new data_cleaner skill and how it’s used in the pipeline.
docs/skills/data_cleaner.md Adds dedicated skill contract/docs for data cleaning behavior and config.
config.yaml Adds data_cleaning configuration and max_features_for_vif knob.
agents/orchestrator.py Prunes low-value columns immediately after dataset load and emits a bus event.
agents/feature_selector.py Adds NaN/inf imputation before scaling and caps VIF cost via prefiltering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread skills/data_cleaner.py
Comment on lines +85 to +92
work = df

# ── 1. Duplicate column names (keep first) ────────────────────────────────
if drop_duplicate:
dup_mask = work.columns.duplicated()
if dup_mask.any():
report["dropped_duplicate"] = [str(c) for c in work.columns[dup_mask]]
work = work.loc[:, ~dup_mask]
Comment thread skills/data_cleaner.py
-------
(filled_df, report) where report['imputed'] maps column → fill value.
"""
report: dict = {"strategy": strategy, "imputed": {}, "n_inf_replaced": 0}
Comment thread skills/data_cleaner.py
Comment on lines +189 to +190
if verbose and report["imputed"]:
print(f" [DataCleaner] Median-imputed NaNs in {len(report['imputed'])} numeric column(s).")
Comment thread agents/orchestrator.py
Comment on lines +549 to +555
cleaned, report = drop_low_value_columns(
df,
max_null_frac=float(dc_cfg.get('max_null_frac', 0.5)),
drop_constant=bool(dc_cfg.get('drop_constant', True)),
protect_cols=protect,
verbose=False,
)
corr_threshold: float = 0.85,
ae_bottleneck_cap: int = 32,
ae_max_iter: int = 200,
max_features_for_vif: int = 150,
# feature names so the LLM still selects interpretable columns.
import pandas as pd
X_for_vif = pd.DataFrame(X_scaled, columns=feature_names)
cap = self.max_features_for_vif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants