For a linear model with independent features, the Shapley value of a feature is its weight times how far its value is from the average. This gives a closed form that matches the exact computation, a useful check on the general method.
Implement linear_shap(w, x, mean), returning w * (x - mean) element-wise.
mean is the average of each feature over background data.Subtract the means from the input, then multiply by the weights.
No results yet
Run your code to check it against the examples, or submit to run every test.