Insights
- class datarobot.insights.base.BaseInsight
Bases:
APIObject
,BrowserMixin
,DatarobotUIMixin
Base Insight class for modern insights
This class serves as a template for modern insights created using the Root Insights framework. It provides most necessary functions for easily implementing classes that wrap specific insights.
-
INSIGHT_NAME:
str
= 'base'
- INSIGHT_DATA = <Any>
- get_uri()
This should define the URI to their browser based interactions
- Return type:
str
- sort(key_name)
Sorts insights data
- Return type:
None
- classmethod from_server_data(data, keep_attrs=None)
Override from_server_data to handle paginated responses
- Return type:
Self
- classmethod compute(entity_id, source=INSIGHTS_SOURCES.VALIDATION, data_slice_id=None, external_dataset_id=None, entity_type=ENTITY_TYPES.DATAROBOT_MODEL, **kwargs)
Submit an insight compute request. You can use create if you want to wait synchronously for the completion of the job. May be overridden by insight subclasses to accept additional parameters.
- Parameters:
entity_id (
str
) – ID of the entity to compute the insight.source (
str
) – Source type to use when computing the insight.data_slice_id (
Optional[str]
) – Data slice ID to use when computing the insight.external_dataset_id (
Optional[str]
) – External dataset ID to use when computing the insight.entity_type (
Optional[ENTITY_TYPES]
) – Type of the entity associated with the insight. Select one of the ENTITY_TYPE enum values, or accept the default, “datarobotModel”.
- Returns:
Status check job entity for the asynchronous insight calculation.
- Return type:
StatusCheckJob
- classmethod create(entity_id, source=INSIGHTS_SOURCES.VALIDATION, data_slice_id=None, external_dataset_id=None, entity_type=ENTITY_TYPES.DATAROBOT_MODEL, max_wait=600, **kwargs)
Create an insight and wait for completion. May be overridden by insight subclasses to accept additional parameters.
- Parameters:
entity_id (
str
) – ID of the entity to compute the insight.source (
str
) – Source type to use when computing the insight.data_slice_id (
Optional[str]
) – Data slice ID to use when computing the insight.external_dataset_id (
Optional[str]
) – External dataset ID to use when computing the insight.entity_type (
Optional[ENTITY_TYPES]
) – Type of the entity associated with the insight. Select one of the ENTITY_TYPE enum values, or accept the default, “datarobotModel”.max_wait (
int
) – Number of seconds to wait for the result.
- Returns:
Entity of the newly or already computed insights.
- Return type:
Self
- classmethod list(entity_id)
List all generated insights.
- Parameters:
entity_id (
str
) – ID of the entity to list all generated insights.- Returns:
List of newly or already computed insights.
- Return type:
List[Any]
- classmethod get(entity_id, source=INSIGHTS_SOURCES.VALIDATION, **kwargs)
Return the first matching insight based on the entity id and kwargs.
- Parameters:
entity_id (
str
) – ID of the entity to retrieve generated insights.source (
str
) – Source type to use when retrieving the insight.
- Returns:
List of newly or already computed insights.
- Return type:
List[Any]
-
INSIGHT_NAME:
- class datarobot.insights.ShapMatrix
Bases:
BaseInsight
Class for SHAP Matrix calculations. Use the standard methods of BaseInsight to compute and retrieve SHAP matrices: * compute: submit a request to compute a SHAP matrix, and return immediately * create: submit a request to compute a SHAP matrix, and wait for it to finish * list: retrieve all ShapMatrix results for a model, possibly on multiple datasets or data slices.
-
INSIGHT_NAME:
str
= 'shapMatrix'
- INSIGHT_DATA = {<Key "base_value" <Any>>: <Float>, <Key "colnames" <Any>>: <List(<String>)>, <Key "index" <Any>>: <List(<Int>)>, <Key "link_function" <Any>>: <String>, <Key "matrix" <Any>>: <List(<List(<Or(<Int>, <Float>)>)>)>}
- property matrix: Any
SHAP matrix values.
- property base_value: float
SHAP base value for the matrix values
- property columns: List[str]
List of columns associated with the SHAP matrix
- property link_function: str
Link function used to generate the SHAP matrix
-
INSIGHT_NAME:
- class datarobot.insights.ShapPreview
Bases:
BaseInsight
Class for SHAP Preview calculations. Use the standard methods of BaseInsight to compute and retrieve SHAP matrices: * compute: submit a request to compute a SHAP preview, and return immediately * create: submit a request to compute a SHAP preview, and wait for it to finish * list: retrieve all ShapPreview results for a model, possibly on multiple datasets or data slices.
- SHAP_PREVIEW_VALUE = <Dict(<Key "feature_name" <String>>, <Key "feature_rank" <Int>>, <Key "feature_value" <String>>, <Key "shap_value" <Float>>)>
- SHAP_PREVIEW_ROW = <Dict(<Key "prediction_value" <Float>>, <Key "preview_values" <List(<Dict(<Key "feature_name" <String>>, <Key "feature_rank" <Int>>, <Key "feature_value" <String>>, <Key "shap_value" <Float>>)>)>>, <Key "row_index" <Int>>, <Key "total_preview_features" <Int>>)>
-
INSIGHT_NAME:
str
= 'shapPreview'
- INSIGHT_DATA = {<Key "previews" <Any>>: <List(<Dict(<Key "prediction_value" <Float>>, <Key "preview_values" <List(<Dict(<Key "feature_name" <String>>, <Key "feature_rank" <Int>>, <Key "feature_value" <String>>, <Key "shap_value" <Float>>)>)>>, <Key "row_index" <Int>>, <Key "total_preview_features" <Int>>)>)>, <Key "previews_count" <Any>>: <Int>}
- property previews: List[Dict[str, Any]]
SHAP preview values
- Returns:
preview – A list of the ShapPreview values for each row
- Return type:
List[Dict[str
,Any]]
- property previews_count: int
Number of shap preview rows
- Return type:
int
- classmethod get(entity_id, source=INSIGHTS_SOURCES.VALIDATION, prediction_filter_row_count=None, prediction_filter_percentiles=None, prediction_filter_operand_first=None, prediction_filter_operand_second=None, prediction_filter_operator=None, feature_filter_count=None, feature_filter_name=None, quick_compute=None, **kwargs)
Return the first matching insight based on the entity id and kwargs.
- Parameters:
entity_id (
str
) – ID of the entity to retrieve generated insights.source (
str
) – The source type to use when retrieving the insight.quick_compute (
bool
, optional) – Sets whether to retrieve the insight that was computed using quick-compute. If not specified, quick_compute is not used for matching.prediction_filter_row_count (
Optional[int]
) – The maximum number of preview rows to return.prediction_filter_percentiles (
Optional[int]
) – The number of percentile intervals to select from the total number of rows. This field will supersede predictionFilterRowCount if both are present.prediction_filter_operand_first (
Optional[float]
) – The first operand to apply to filtered predictions.prediction_filter_operand_second (
Optional[float]
) – The second operand to apply to filtered predictions.prediction_filter_operator (
Optional[str]
) – The operator to apply to filtered predictions.feature_filter_count (
Optional[int]
) – The maximum number of features to return for each preview.feature_filter_name (
Optional[str]
) – The names of specific features to return for each preview.quick_compute – When enabled, limits the rows used from the selected source subset by default. When disabled, all rows are used.
- Returns:
List of newly or already computed insights.
- Return type:
List[Any]
- class datarobot.insights.ShapImpact
Bases:
BaseInsight
Class for SHAP Impact calculations. Use the standard methods of BaseInsight to compute and retrieve SHAP matrices: * compute: submit a request to compute a SHAP impact, and return immediately * create: submit a request to compute a SHAP impact, and wait for it to finish * list: retrieve all ShapImpact results for a model, possibly on multiple datasets or data slices.
-
INSIGHT_NAME:
str
= 'shapImpact'
- INSIGHT_DATA = {'base_value': <List(<Float>)>, 'capping': typing.Optional[<Or(<Null>, <Dict(<Key "left" <Or(<String>, <Float>, <Null>)>>, <Key "right" <Or(<String>, <Float>, <Null>)>>)>)>], 'link': <Or(<String>, <Null>)>, 'row_count': typing.Optional[<Int>], 'shap_impacts': <Or(<List(<List(<Or(<Int>, <Float>)>)>)>, <Dict(<Key "featureName" <String>>, <Key "impactNormalized" <Float>>, <Key "impactUnnormalized" <Float>>)>)>}
- sort(key_name='-impact_normalized')
Sorts insights data by key name.
- Parameters:
key_name (
str
) – item key name to sort data. One of ‘feature_name’, ‘impact_normalized’ or ‘impact_unnormalized’. Starting with ‘-’ reverses sort order. Default ‘-impact_normalized’- Return type:
None
- property shap_impacts: List[List[Any]]
SHAP impact values
- Returns:
A list of the SHAP impact values
- Return type:
shap impacts
- property base_value: List[float]
A list of base prediction values
- property capping: Dict[str, Any] | None
Capping for the models in the blender
- property link: str | None
Shared link function of the models in the blender
- property row_count: int | None
Number of SHAP impact rows. This is deprecated.
-
INSIGHT_NAME:
- class datarobot.insights.ShapDistributions
Bases:
BaseInsight
Class for SHAP Distributions calculations. Use the standard methods of BaseInsight to compute and retrieve SHAP matrices and SHAP impact: * compute: submit a request to compute a SHAP distributions, and return immediately * create: submit a request to compute a SHAP distributions, and wait for it to finish * list: retrieve all ShapDistributions results for a model, possibly on multiple datasets or data slices.
- SHAP_DISTRIBUTION_VALUE = <Dict(<Key "feature_rank" <Int>>, <Key "feature_value" <String>>, <Key "prediction_value" <Float>>, <Key "row_index" <Int>>, <Key "shap_value" <Float>>)>
- SHAP_DISTRIBUTIONS_ROW = <Dict(<Key "feature" <String>>, <Key "feature_type" <String>>, <Key "impact_normalized" <Float>>, <Key "impact_unnormalized" <Float>>, <Key "shap_values" <List(<Dict(<Key "feature_rank" <Int>>, <Key "feature_value" <String>>, <Key "prediction_value" <Float>>, <Key "row_index" <Int>>, <Key "shap_value" <Float>>)>)>>)>
-
INSIGHT_NAME:
str
= 'shapDistributions'
- INSIGHT_DATA = {<Key "features" <Any>>: <List(<Dict(<Key "feature" <String>>, <Key "feature_type" <String>>, <Key "impact_normalized" <Float>>, <Key "impact_unnormalized" <Float>>, <Key "shap_values" <List(<Dict(<Key "feature_rank" <Int>>, <Key "feature_value" <String>>, <Key "prediction_value" <Float>>, <Key "row_index" <Int>>, <Key "shap_value" <Float>>)>)>>)>)>, <Key "total_features_count" <Any>>: <Int>}
- property features: List[Dict[str, Any]]
SHAP feature values
- Returns:
features – A list of the ShapDistributions values for each row
- Return type:
List[Dict[str
,Any]]
- property total_features_count: int
Number of shap distributions rows
- Return type:
int