Build room discussion - SHAP & Overfitting
During the Build session event, my team received two interesting questions, one about the practical benefits of SHAP and another regarding measures to prevent overfitting. I’d like to provide more extensive answers here, hoping it’ll be helpful to everyone.
1. What is SHAP, and how can it benefit us in machine learning or data science projects?
Imagine you've trained an ML model to detect cancer or identify bank customers eligible for loan approval.
What's the last thing you'd typically check? Perhaps the model's performance on unseen data or average cross-validation (CV) scores on validation sets.
But what's the first thing a doctor or bank loan officer might ask? They'd likely want to know how to trust your model. How can they clearly explain to the patient why they have cancer or justify to the client why their loan was denied?
Unfortunately, they're usually not interested in our model’s impressive accuracy or F1-score values alone.
This is where a tool like SHAP (Shapley Additive exPlanations) or Eli5 becomes invaluable. SHAP links the model's predictions directly to input features, showing precisely which features most positively or negatively influenced each prediction.
For example, it could explain: “The patient has a high likelihood of cancer because of elevated levels of 'x' in their blood test and a family history of the disease.”
SHAP calculates these contributions based on concepts from game theory. However, it's essential to address collinearity among features first to ensure reliable interpretations. This can be managed by applying regularization in linear or tree-based models. Additionally, SHAP can even guide feature selection post-training by identifying the most relevant predictors.
2. How did you ensure your model didn't overfit, given the small sample size?
As discussed in the meeting, dataset size isn't the sole factor influencing overfitting. Usually, overfitting occurs when the complexity of your model exceeds what your data and problem complexity justify.
In our case, the problem was relatively straightforward: a binary classification with small class overlap. Therefore, simpler models such as linear or tree-based models were sufficient to capture the decision boundary effectively without needing excessive complexity.
Additionally, our sample size (~700 data points) was sufficient for these simpler models to learn accurately without overfitting. However, the same size might be insufficient if someone attempted more complex neural network-based approaches. In general scenarios, using regularization methods (like Ridge, Lasso, ElasticNet, or early stopping) can significantly mitigate overfitting risks. Dimensionality reduction (e.g., PCA or UMAP) can also help by simplifying the feature space, especially when dealing with high-dimensional datasets.
I hope these insights will be helpful for other teams as well. Please feel free to share your opinions in the comments!