SHAP

class datarobot.models.ShapImpact

Represents SHAP impact score for a feature in a model.

Added in version v2.21.

Notes

SHAP impact score for a feature has the following structure:

  • feature_name : (str) the feature name in dataset

  • impact_normalized : (float) normalized impact score value (largest value is 1)

  • impact_unnormalized : (float) raw impact score value

Variables:
  • count (int) – the number of SHAP Impact object returned

  • row_count (int or None) – the sample size (specified in rows) to use for Shap Impact computation

  • shap_impacts (list) – a list which contains SHAP impact scores for top 1000 features used by a model

classmethod create(cls, project_id, model_id, row_count=None)

Create SHAP impact for the specified model.

Parameters:
  • project_id (str) – id of the project the model belongs to

  • model_id (str) – id of the model to calculate shap impact for

  • row_count (int) – the sample size (specified in rows) to use for Feature Impact computation

Returns:

job – an instance of created async job

Return type:

Job

classmethod get(cls, project_id, model_id)

Retrieve SHAP impact scores for features in a model.

Parameters:
  • project_id (str) – id of the project the model belongs to

  • model_id (str) – id of the model the SHAP impact is for

Returns:

shap_impact – The queried instance.

Return type:

ShapImpact

Raises:

ClientError – If the project or model does not exist or the SHAP impact has not been computed.