Explore Library
Code QuizIntermediate

Feature Importance from Ensembles

Catching a normalization mistake when averaging tree importances.

Codepython
import numpy as np

def aggregate_importance(trees, n_features):
    total = np.zeros(n_features)
    for t in trees:
        total += t.feature_importances_
    # average importance across the forest
    return total / n_features

What is the bug in this importance-aggregation function?