Ethical AI · Intermediate level

Intermediate level · Module 6: Introduction to Explainable AI · Lesson 2 of 3

Global Explanations: Coefficients and Permutation Importance

Learners read logistic regression coefficients carefully and compute permutation importance with scikit-learn to see which inputs the model relies on.

In this lesson you will

  • Interpret model coefficients with care
  • Compute and plot permutation importance

Key concepts

coefficientsfeature scalingpermutation_importancetest-set importancecorrelated features

The lesson

In a logistic regression, a positive coefficient increases the predicted chance of passing. Coefficients can only be compared when features are on the same scale, so standardise them first (for example with StandardScaler in a pipeline).

Permutation importance works for any model. It shuffles one feature at a time on the test set and measures how much the score drops. sklearn.inspection.permutation_importance(model, X_test, y_test, n_repeats=10, random_state=0) returns the mean and spread of the drop for each feature.

Correlated features share importance, so shuffling one may show a small drop because another carries the same information. If school type and county type are strongly related, interpret their importance together, and look for proxies.

Step by step

  1. Fit a pipeline with StandardScaler and LogisticRegression and print the coefficients with feature names.
  2. Run permutation_importance on the test set.
  3. Plot the mean importances with error bars in Matplotlib.
  4. Write which features drive predictions and whether any could be a proxy for a sensitive attribute.

Practice activity

Produce a global explanation of the project model with coefficients and permutation importance.

Expected result: A correct chart and a careful interpretation that mentions scaling, correlation and possible proxies.

Check your understanding

  1. Why standardise features before comparing coefficients?

    Show answer

    So that coefficients are on comparable scales.

  2. How does permutation importance work?

    Show answer

    It shuffles one feature and measures how much the model's score drops.

Further learning

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.