[Python] Title: Why Are My SHAP Values Dimensions [sample_num, feature, class] Instead of...

Discussão em 'Python' iniciado por Stack, Março 16, 2025.

  1. Stack

    Stack Membro Participativo

    Why do all AIs believe that the SHAP values are calculated as follows?

    X_sample = pd.DataFrame(X_train_resampled, columns=X.columns)[:500]
    explainer_rf = shap.TreeExplainer(rf_model)
    shap_values_rf = explainer_rf.shap_values(X_sample)


    The resulting shap_values_rf dimensions should be [class, sample_num, feature], but in reality, my output is [sample_num, feature, class]. I urgently need a reasonable explanation for this.

    null,I have tried many AIs to generate SHAP summary plots, and there seems to be an issue with the dimensions. Even when using the default Iris dataset, the problems described persist. The AI always assumes that the class dimension is in the first position.

    Continue reading...

Compartilhe esta Página