View source: R/calculateSHAP.R
calculate_SHAP_values | R Documentation |
This function calculates SHAP values for a given dataset using a provided model. It then identifies significant features based on the SHAP values for the specified class. Additionally, it prepares a long-format data frame of individual SHAP values suitable for visualization.
calculate_SHAP_values(model, data, class_index = 1, shap_std_dev_factor = 0.5)
model |
The trained model for which SHAP values are to be calculated. |
data |
A matrix or data frame of input features for SHAP value calculation. |
class_index |
Index of the class for which to calculate SHAP values. For binary classification (e.g., target 1 = "Right", target 0 = "Left"), this parameter determines the class perspective for SHAP analysis. In the demo_rnaseq_data dataset:
|
shap_std_dev_factor |
Factor to determine the cutoff for significant SHAP values. Default is 0.5. For example 0.5 is considered conservative as it means you are selecting features whose mean absolute SHAP values are above the mean plus half of the standard deviation. |
A list containing three elements:
shap_values: A data frame with SHAP values for each feature.
significant_features: A data frame with significant features based on the cutoff.
long_shap_data: A long-format data frame of individual SHAP values for each feature.
shapvals <- calculate_SHAP_values(fitting_results$model, processed_training_data$X_training_mat, class_index = 1, shap_std_dev_factor = 0.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.