Arize AI

Feature Importance

Assign a certain score to each feature to weigh how much or how little it impacted the outcome


Feature importance is a compilation of a class of techniques that take in all the features related to making a model prediction and assign a certain score to each feature to weigh how much or how little it impacted the outcome.
Important: Arize does NOT REQUIRE a model artifact upload to use feature importance. Feature Importance values should be calculated by the user or a surrogate model and then logged to Arize.
SHAP Values (a feature importance technique) can be logged along with the inferences or after.

How to Send Feature Importance to Arize

Arize supports 2 methods for ingesting and visualizing feature importance, with tradeoffs:
Tradeoffs of feature importance generation methods

Code Example

# 1. Generate the Shap Values and save as Dataframe
explainer = shap.TreeExplainer(tree_model)
shap_values = explainer.shap_values(X_data)
shap_dataframe = pd.DataFrame(
shap_values, columns=[f"{fn}_shap" for fn in data["feature_names"]]
# 2.Define the Schema. Link the feature column with its corresponding shap column
shap_cols = shap_dataframe.columns
schema = Schema(
feature_column_names= feature_cols,
shap_values_column_names=dict(zip(feature_cols, shap_cols)),
# Log the dataframe with the schema mapping
response = arize_client.log(
model_version= "v1",
Questions? Email us at [email protected]com or Slack us in the #arize-support channel
Last modified 30d ago