pyreal.RealApp.produce_feature_contributions#
- RealApp.produce_feature_contributions(x_orig, model_id=None, x_train_orig=None, y_train=None, algorithm=None, format_output=True, shap_type=None, force_refit=False, training_size=None, num_features=None, select_by='absolute', include_average_values=False)[source]#
Produce a feature contribution explanation
- Parameters:
x_orig (DataFrame of shape (n_instances, n_features) or Series of length (n_features)) – Input(s) to explain
model_id (string or int) – ID of model to explain
x_train_orig (DataFrame) – Data to fit on, if not provided during initialization
y_train (DataFrame or Series) – Training targets to fit on, if not provided during initialization
algorithm (string) – Name of algorithm
format_output (Boolean) – If False, return output as a single DataFrame. Formatted outputs are more usable but take longer to generate.
shap_type (string) – If algorithm=”shap”, type of SHAP explainer to use
force_refit (Boolean) – If True, initialize and fit a new explainer even if the appropriate explainer already exists
training_size (int) – Number of rows to use in fitting explainer
num_features (int) – Number of features to include in the explanation. If None, include all features
select_by (one of "absolute", "min", "max") – If num_features is not None, method to use for selecting which features to show. Not used if num_features is None
include_average_values (Boolean) – If True, include the average/mode value of each feature in the output
- Returns:
- dictionary (if x_orig is DataFrame) or DataFrame (if x_orig is Series)
One dataframe per id, with each row representing a feature, and four columns: Feature Name Feature Value Contribution Average/Mode