# Ensembles of Random SHAPs
## 4 Modifications of SHAP
### Ensemble of Random SHAPs Generated by the Random Forest  
In order to control the process of the random feature selection, it is reasonable to choose features for producing \(\mathbf{z}_{1},\ldots,\mathbf{z}_{N}\) in accordance with some probability distribution different from the uniform distribution, which would take into account the preliminary importance of features. The intuition behind this modification is to reduce the selection of unimportant features which do not impact on the black-box prediction corresponding to \(\mathbf{x}\) a priori. One of the ways to implement this control is to compute the preliminary feature importance by means of the random forest. Although it is known that the random forest does not always give acceptable results related to the feature selection problem, the proposed approach does not have this drawback because we propose to train the random forest on instances generated in the neighborhood of explained instance \(\mathbf{x}\). The next algorithm is called the ensemble of random SHAPs generated by the random forest (ER-SHAP-RF) algorithm. The random forest plays a role of the important feature selection model. It can be also viewed as some kind of pre-training for important features. The idea to train the random forest on generated neighbors allows us to implement a preliminary explanation method. It should be noted that the random forest is not a unique model for selecting important features. There are many methods [59], which could be used for solving this task. We use the random forest as one of the popular and simple methods having a few parameters. In the same way, the linear regression model could be used instead of the random forest. The random forest can be used as an explanation model by applying an approach proposed by [60] based on a scalable method for transforming a decision forest into a single decision tree which is interpretable. The LIME method can be also applied to obtain the probability distribution of features. In the case of its use, normalized absolute values of linear regression coefficients can be regarded as the probability distribution of features. For solving the feature selection task by random forests, we use the well-known simple method [19]. According to this method, for every tree from the random forest, we compute how much the impurity is decreased by a feature. The more the feature decreases the impurity, the more important the feature is. The impurity decreasing is averaged across all trees in the random forest, and the obtained value corresponds to the final importance of the feature. The proposed approach may lead to small probabilities of unimportant features. However, it does not mean that these features will not selected for using in an explanation by means of SHAP. They have a smaller chance to be selected under condition that their probabilities are not equal to zero. This implies that the classification or regression models for constructing the probability distribution \(P\) should not provide some sparse predictions such as the Lasso because only a small part of features in this case will take part in explanation. A general scheme of ER-SHAP-RF is shown in Figure 3 where a number, say \(M\), of neighbors \(\mathbf{h}_{1},\ldots,\mathbf{h}_{M}\) are generated around the instance \(\mathbf{x}\) to be explained. Every generated neighbor \(\mathbf{h}_{j}\) is fed into the black-box model to obtain its class label \(y_{j}^{*}\). It should be noted that the training instances can be taken as neighbors. However, they should be classified by using the black-box model in order to take into account this model in an explanation. Having points \((\mathbf{h}_{j},y_{j}^{*})\), we train the random forest which provides a feature importance measure in the form of the probability distribution \(P=(p_{1},\ldots,p_{m})\).