Insights

class datarobot.insights.base.BaseInsight(id, entity_id, project_id, source, data, data_slice_id=None, external_dataset_id=None)

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.

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:
StatusCheckJob

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:
Self

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[Any]

List of newly or already computed insights.

Return type:

List[Self]

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[Any]

List of newly or already computed insights.

Return type:

Self

class datarobot.insights.ShapMatrix(id, entity_id, project_id, source, data, data_slice_id=None, external_dataset_id=None)

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.

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

Link function used to generate the SHAP matrix

class datarobot.insights.ShapPreview(id, entity_id, project_id, source, data, data_slice_id=None, external_dataset_id=None)

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.

property previews: List[Dict[str, Any]]

SHAP preview values

Returns:
previewList[Dict[str, Any]]

A list of the ShapPreview values for each row

property previews_count: int

Number of shap preview rows

Returns:
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

Source type to use when retrieving the insight.

prediction_filter_row_count: int, optional

The maximum number of preview rows to return.

prediction_filter_percentiles: int, optional

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: float, optional

The first operand to apply to filtered predictions.

prediction_filter_operand_second: float, optional

The second operand to apply to filtered predictions.

prediction_filter_operator: str, optional

The operator to apply to filtered predictions.

feature_filter_count: int, optional

The maximum number of features to return for each preview.

feature_filter_name: str, optional

The names of specific features to return for each preview.

quick_compute: bool, optional

When enabled, limits the rows used from the selected source subset by default. When disabled, all rows are used.

Returns:
List[Any]

List of newly or already computed insights.

Return type:

Self

class datarobot.insights.ShapImpact(id, entity_id, project_id, source, data, data_slice_id=None, external_dataset_id=None)

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.

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:
shap impacts

A list of the SHAP impact values

property base_value: List[float]

A list of base prediction values

property capping: Dict[str, Any] | None

Capping for the models in the blender

Shared link function of the models in the blender

property row_count: int | None

Number of SHAP impact rows. This is deprecated.

class datarobot.insights.ShapDistributions(id, entity_id, project_id, source, data, data_slice_id=None, external_dataset_id=None)

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.

property features: List[Dict[str, Any]]

SHAP feature values

Returns:
featuresList[Dict[str, Any]]

A list of the ShapDistributions values for each row

property total_features_count: int

Number of shap distributions rows

Returns:
int