Sitemap
JM tan

JM tan

Self-learned data science practitioner exploring machine learning through Kaggle competitions and experiment driven projects

SHAP Said These Features Didn’t Matter … BUT Removing Them Hurt Performance.

Part 2 of a 4-part Kaggle series — Feature Selection with SHAP in the Ames Housing Competition

11 min readJun 30, 2026

--

Press enter or click to view image in full size
Many nails seems insignificant, but together they hold the structure (AI-generated)

“The experiments, analysis, and interpretations are based on my own work, ChatGPT was used to assist with editing, wording, and improving readability.”

When More Features Stop Helping

In Part 1, I focused on improving the model through feature engineering. New interaction terms, transformations, and encoded variables expanded the dataset far beyond the original 79 features.

Some changes improved performance, but a recurring pattern began to appear — better cross-validation scores did not always translate to better leaderboard results.

Even after testing multiple feature combinations, the inconsistency remained. Features that appeared helpful during validation often failed to improve unseen performance.

At the same time, the feature space had grown substantially. While tree-based models are generally robust to irrelevant features, they are not completely immune to noise, especially on a relatively small dataset like Ames Housing.

This raised a new question — Had I introduced too much noise?

A New Hypothesis: Can Fewer Features Generalize Better?

If some of these engineered features were redundant or weak, removing them should improve generalization, theoretically. This leads to a natural hypothesis — If we keep only the most important features, the model should perform better on unseen data.

To test this idea, I needed a way to quantify feature importance — not based on simple statistics, but based on how the model itself uses each feature during prediction. This naturally leads to feature selection.

Press enter or click to view image in full size
Investigation Roadmap

Feature Selection Approaches

Several feature selection approaches exist, including filter, wrapper, and embedded methods. Since all models in this project are tree-based, embedded approaches naturally align with the modeling approach..

Why SHAP?

Within embedded methods, tree-based models already provide built-in feature importance measures, such as split gain or frequency. However, they often reflect how frequently a feature is used in splits, but do not fully capture the magnitude or direction of its impact on predictions.

SHAP (SHapley Additive exPlanations) addresses this by decomposing each prediction into individual feature contributions. Instead of simply identifying which features are used most often, it allows us to understand:

  • how much each feature contributes to the prediction
  • whether its impact is positive or negative
  • how its effect varies across different observations

This makes SHAP particularly useful not just for interpretation, but also for guiding feature selection based on the model’s actual behavior.

⚠️Concern Before Starting

At this point, I had an important doubt.

Low importance does not necessarily mean a feature is useless. Some variables may only matter for certain observations or under specific conditions.

Tree-based models also perform a form of feature selection internally, which raises an important question:

If the model already ignores weak features, does removing them actually help?

Despite these concerns, the hypothesis still seemed reasonable:

If low-importance features mainly contribute noise, removing them should improve generalization.

The only way to know was to test it.

Methodology Design

With this in mind, the next step was to determine which features truly contributed to the models.

SHAP-Based Feature Importance

SHAP decomposes model predictions into additive feature contributions. For each model:

  • SHAP values were computed on the training data
  • the absolute SHAP values were aggregated across all samples
  • the mean value was used as the global importance score

For each feature, the mean(abs(shap_values)) across all observations was calculated, which captures the magnitude of a feature’s contribution regardless of direction. Higher values indicate stronger overall influence on the model’s predictions.

Selection Strategy

Rather than selecting a fixed number of features, a cumulative importance threshold was applied. This allows the number of selected features to adapt to each model’s importance distribution, rather than relying on an arbitrary cutoff.

Features were ranked by importance, and only those contributing to the top 95% of total SHAP importance were retained, to remove only the weakest contributors while preserving most of the model’s learned information.

Model Retraining and Evaluation

After selecting the “more important” features:

  • the dataset was reconstructed using only the reduced feature set
  • models were retrained using the same cross-validation setup
  • performance was evaluated using both cross-validation RMSE and leaderboard results

⚠️Do SHAP Before or After One-Hot Encoding?

HistGradientBoosting and XGBoost require numerical inputs and rely on OHE, so for these two models, this raises an important implementation question — Should SHAP be computed on the original categorical features or on the encoded features?

Trade-off

Option A: Raw Categorical Features
✅ Importance is easier to interpret at the feature level
❌ Does not align with how some models actually learn.

Option B: One-Hot Features
✅ Reflects the true structure seen by the model and preserves how splits are made during training
❌ Introduces fragmentation as the importance is distributed across multiple columns split by a single categorical feature

Decision

In this experiment, SHAP values were computed on the actual input representation used by each model.

  • SHAP values were calculated at the encoded feature level independently, i.e. categorical_feature_A_1, categorical_feature_A_2, …
  • Then aggregated back each the SHAP values to the original feature level, i.e. categorical_feature_A
Aggregating SHAP values from OHE variables back to the original feature level

This ensures that:

  • the importance scores reflect how the model actually learns, while still allowing interpretation at the original feature level, and
  • the importance of a single categorical variable is not fragmented across multiple columns — which would otherwise dilute its apparent impact and make feature-level comparison misleading

Results & Observations

Press enter or click to view image in full size
Each point represents a model under a specific stage.
Points closer to the lower-left indicate better validation and leaderboard performance.

After applying SHAP-based feature selection, the results were more underwhelming than expected. Reducing the feature set to the top 95% of cumulative SHAP importance did not lead to consistent improvements.

Across different models, the impact of feature selection varied in cross-validation:

  • CatBoost showed slight improvement
  • XGBoost deteriorated
  • LightGBM and HistGradientBoosting remained relatively stable

However, despite these differences, all models experienced a decline in leaderboard performance:

  • Feature pruning does not guarantee improvement
    Reducing the feature set based on SHAP importance did not result in clear performance gains. In most cases, performance either remained similar or declined.
  • Cross-validation improvements can be misleading
    Even when CV improved, this did not translate into better leaderboard performance. This reinforces a key lesson from Part 1 — Improvements in cross-validation do not always reflect better generalization.
  • The effect of feature selection is not consistent across models
    Different models responded differently to the same pruning strategy, suggesting that the relationship between feature importance and model performance is not straightforward.

These results raise an important question — If many features appear low in importance, why doesn’t removing them improve performance?

Understanding the Model With SHAP

To better understand why feature pruning did not improve performance, I examined how each model actually utilized the feature space using SHAP.

How to read the SHAP Summary Plot

Each point in the summary plot represents a single observation.

  • The x-axis shows the SHAP value, indicating how much a feature increases or decreases the predicted house price
  • The color represents the feature value, with blue indicating lower values and red indicating higher values
  • Features are ordered by their overall importance, calculated as the mean absolute SHAP value across all observations
  • The horizontal spread shows how strongly a feature affects different observations

This allows us to move beyond simple feature ranking and understand how features influence predictions across different observations.

XGBoost

Press enter or click to view image in full size
XGBoost — SHAP Summary Plot
  • TotalSF has an exceptionally wide SHAP range, while the remaining features contribute much smaller effects.
  • After the first variables, SHAP magnitudes decline rapidly, suggesting that the model relies heavily on a small set of highly predictive signals.

HistGradientBoosting

Press enter or click to view image in full size
HistGradientBoosting — SHAP Summary Plot
  • HistGradientBoosting still relies heavily on TotalSF, but secondary variables contribute somewhat more consistently than in XGBoost.
  • This flatter importance distribution suggests that the model relies more evenly on both dominant and secondary predictors.

LightGBM

Press enter or click to view image in full size
LightGBM XGBoost — SHAP Summary Plot
*Gray points indicate categorical variables without a natural ordering.
  • LightGBM assigns the highest importance to OverallQual, suggesting a greater emphasis on overall property quality.
  • This model exhibits a broader distribution of feature contributions, with variables such as CentralAir, and several garage- and basement-related features maintaining moderate SHAP impact beyond the dominant predictors.

A wider SHAP spread does not necessarily imply higher importance

For example, HouseAge shows more extreme effects for some houses, while ExterQual contributes more consistently across the dataset and therefore ranks higher.

CatBoost

Press enter or click to view image in full size
CatBoost — SHAP Summary Plot
  • TotalSF remains the dominant feature, while GrLivArea becomes much more important, suggesting that CatBoost places greater emphasis on finished living space.
  • Several categorical features, particularly Neighborhood and zoning-related features, exhibit less fragmented SHAP patterns.
  • This behavior is consistent with CatBoost’s ability to handle categorical variables directly rather than through one-hot encoding.

Key Observations Across Models

Despite differences in how the models allocate importance, several consistent patterns emerge across all four models.

  1. Strong signals are concentrated in a few features

A small number of features consistently dominated the importance rankings across all models. For example, features like TotalSF and OverallQual show large SHAP magnitudes with clear directional patterns.

Get JM tan’s stories in your inbox

Join Medium for free to get updates from this writer.

This consistency suggests that a substantial portion of the predictive power is driven by a limited set of strong signals.

2. Many weaker features contribute incremental signals

Beyond the dominant predictors, numerous variables exhibit relatively small but consistently non-zero SHAP values. Features related to garages, basements, and neighborhood characteristics often contribute modest effects across many observations.

Although these variables individually appear less important, their collective contributions help refine model predictions. This helps explain why removing low-importance features did not improve performance — and may even hurt generalization.

Core Insights: Why SHAP Didn’t Work

The SHAP analysis reveals an important lesson — identifying important features does not necessarily mean we can safely remove the rest. While SHAP provides a powerful way to understand how models use features, translating these insights into feature selection is not always straightforward, especially for tree-based models.

  1. Why SHAP Provided Limited Benefit for Tree Models

Tree-based ensemble models, such as gradient boosting methods, already perform a form of implicit feature selection during training. At each split, the model naturally prioritizes features that provide the highest information gain, while less useful features receive fewer or weaker splits. As a result:

  • truly irrelevant features tend to have minimal impact
  • the model is already robust to noise in the feature space

In this context, explicitly removing features based on importance scores often provides limited additional benefit. Moreover, SHAP importance is derived from the trained model itself.

If the model has already learned to downweight less useful features,

removing them afterward does not significantly change its behavior.

2. Models Rely on Many Weak Signals

One key pattern observed from the SHAP summary plots is that feature importance is not only concentrated in a few dominant variables, but also distributed across many lower-ranked features. While these features individually contribute little, they are combined to make incremental adjustments to predictions.

As a result, feature pruning based purely on importance ranking may unintentionally remove useful information, even when individual features appear insignificant. In other words,

the model does not just learn “a few strong rules”, but rather a collection of many small adjustments.

Weak features can become strong collectively.

3. Feature Importance ≠ Dispensability

Earlier, we questioned whether low-importance features could be safely removed. The results from this experiment suggest that this assumption does not hold. From the SHAP summary plots, we observe that

  • even low-importance features can still carry useful signals
  • some features only become important under specific conditions

Removing them may not eliminate noise — instead, it may remove subtle information that helps the model make more precise predictions. In other words,

A feature can appear unimportant in isolation, but still be valuable as part of a broader system of interactions.

4. Feature Interactions Break Importance Ranking

Another limitation of SHAP-based selection is that feature importance is inherently marginal, not joint. SHAP values measure the average contribution of a feature across many contexts. However, they do not fully capture higher-order interactions and dependencies between features.

As a result, a feature may appear low in importance on its own but still play a critical role when combined with other features. Removing such features can break these interactions, leading to performance degradation — even if the individual importance score is low.

5. Dataset Size Amplifies the Risk

The Ames Housing dataset is relatively small, which makes the model more sensitive to change in the feature space. In smaller datasets increases the risk of losing useful variance and degrading generalization performance, due to:

  • each feature contributes to capturing limited patterns in the data
  • removing features reduces the diversity of available signals

Which means:

removing features from small datasets may discard more information than expected.

6. When Feature Selection Actually Helps

Despite these findings, feature selection is not inherently ineffective — it simply depends on the context. Feature selection tends to be more beneficial when:

  • working with high-dimensional datasets (e.g., thousands of features)
  • dealing with noisy or redundant features
  • using models sensitive to irrelevant variables (e.g., linear models)

In these scenarios, reducing the feature space can:

  • improve model stability
  • reduce overfitting
  • enhance interpretability

Thus, the usefulness of feature selection depends on both the model and the dataset.

What This Experiment Really Taught Me

In Part 1, the focus was on improving performance through feature engineering. While some features helped, a recurring pattern emerged — improvements in cross-validation did not always translate to better leaderboard results.

In this part, I explored whether reducing the feature space using SHAP-based importance could improve generalization. The intuition was simple: if some features contribute little, removing them should help the model focus on stronger signals.

However, the results were more counterintuitive than expected. Despite using a principled approach to rank and select features, performance did not improve — and in many cases, it deteriorated.

Through the SHAP analysis, a clearer picture gradually emerged:

  • low-importance features can still carry useful signals
  • feature contributions are often distributed rather than isolated
  • interactions between features are not fully captured by importance alone

This experiment ultimately changed how I think about feature selection. Understanding how a model uses features is not the same as understanding which features can be safely removed.

SHAP proved to be an excellent tool for interpretation, but not necessarily a reliable shortcut for improving performance.

Key Takeaways

  • Tree-based ensemble models already perform a degree of feature selection during training.
  • Low feature importance does not necessarily mean a feature can be removed safely.
  • Many small contributions can collectively improve model predictions.
  • Cross-validation improvements do not always translate into better generalization.
  • SHAP is highly effective for understanding model behavior, but its importance rankings do not automatically produce better feature subsets.
  • Improving interpretability and improving performance are not always the same objective.

Next Article

— Parameter Tuning

If feature selection is not the answer, the next question becomes —

How can we better guide the model to learn from the same features more effectively?

This leads to the next step in the workflow — parameter tuning. Instead of changing what the model learns from, the focus shifts toward how the model learns by adjusting model complexity, regularization, and learning dynamics to improve generalization.

Resources

< — Feature Engineering >
< >
< >
< >

--

--

JM tan
JM tan

Written by JM tan

Self-learned data science practitioner exploring machine learning through Kaggle competitions and experiment driven projects