liveBook · Manning

Importance score

As explained in Outlier Detection in Python

Feature importance is a quantitative indication of how much an input feature contributes to a model’s prediction, score, or decision.

An importance score indicates how relevant an input feature is to an outlier detector’s score. Global importance summarizes relevance across records; local importance identifies features relevant to one record. Both help answer a question that an outlier label alone cannot: which measurements deserve closer inspection? section 13.2.1

For a fitted detector, SHAP can estimate importances from the original feature columns. A global bar plot ranks features across the data, while a beeswarm plot also shows whether low or high values tend to contribute more to outlier scores. Selecting one explanation produces a local plot for that record. In PyOD, IForest offers detector-level importances; ECOD and COPOD offer record-level views of exceptional feature values. section 13.2.1 section 6.15

Listing 13.2 Determining the SHAP global feature importances
import shap
df = df.sort_values('IF Score')                                  #1
explainer = shap.Explainer(det)                                  #2
explanation = explainer(df[orig_features])

The SHAP workflow passes a detector to Explainer, then evaluates it on the original feature columns. Sorting by outlier score puts the highest-scored record first for a subsequent local plot. section 13.2.1

Reading an abalone explanation

For an anomalous abalone record, high importance for whole weight and diameter directs attention to those measurements. It does not establish whether each value is unusual on its own or whether their combination is unusual. Across the dataset, SHAP and PyOD can rank features differently: PyOD’s IForest importances are more approximate and, in this example, gave numeric features nearly identical scores. section 13.2.5 section 13.2.1

Interpret importance in light of the detector. For univariate detectors such as ECOD and COPOD, exceptional values may explain much of a score. BHAD sums univariate tests and supplies both local and global importances; its feature-level results can account for its score because it does not detect unusual combinations. For detectors sensitive to interactions or internal outliers, importance alone is a partial explanation. Understand what the features mean, inspect scores rather than labels alone, and use complementary explanations—such as proxy models or counterfactuals—when the feature ranking leaves the score unclear. section 13.2.1 section 13.3.2 section 13.2.5

How Outlier Detection in Python covers it

How deep it goes
Distinguishes global from local importance and demonstrates plotting workflows, while emphasizing that rankings need not fully explain scores.
Examples
Uses abalone outlier scores, SHAP plots, PyOD IForest rankings, and BHAD’s local and global explanations.
What it assumes
Assumes a scored dataset and a fitted detector for the SHAP workflow; defines the distinction between global and local importance.
What you can do after
Apply it via SHAP or supported detectors to rank relevant features, then assess whether those rankings adequately explain an outlier score.
How it connects
Links feature importance to outlier detection, explainable AI, univariate tests, feature interactions, proxy models, and counterfactuals.

Also explained in

Compare how 6 books explain importance score →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Outlier Detection in Python. The section links point to the parts of the book it draws on.