skills/tabular/recursive-feature-elimination/SKILL.md
Uses RFE with a tree estimator to iteratively remove least important features, selecting an optimal compact feature set.
npx skillsauth add wenmin-wu/ds-skills tabular-recursive-feature-eliminationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Start with all features, train a tree model, remove the least important feature(s), repeat until the desired count remains. RFE is more robust than single-pass importance ranking because feature importance changes as correlated features are removed. Use a fast estimator (DecisionTree) for the elimination loop, then train the final model (LightGBM) on selected features.
from sklearn.feature_selection import RFE
from sklearn.tree import DecisionTreeClassifier
def select_features_rfe(X_train, y_train, n_features=8):
"""Select top features via recursive elimination."""
rfe = RFE(
estimator=DecisionTreeClassifier(random_state=42),
n_features_to_select=n_features,
step=1, # remove 1 feature per iteration
)
rfe.fit(X_train, y_train)
selected = X_train.columns[rfe.support_].tolist()
ranking = dict(zip(X_train.columns, rfe.ranking_))
print(f"Selected {len(selected)} features: {selected}")
return selected, ranking
# Usage
features, ranking = select_features_rfe(X_train, y_train, n_features=8)
model.fit(X_train[features], y_train)
data-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF