BaşlayınÜcretsiz Başlayın

Computing feature importance with random forests

As a data scientist at a financial consulting firm, you have developed a random forest classifier that classifies individuals according to their income levels. Now, you need to explain the model by analyzing feature importance to determine the key factors for predicting income, enabling more targeted market segmentation and improving strategic decision-making.

matplotlib.pyplot has been imported as plt. X_train and y_train are pre-loaded for you.

Bu egzersiz

Explainable AI in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Extract the feature importances from the model.
  • Plot the feature_importances.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

model = RandomForestClassifier(random_state=42)
model.fit(X_train, y_train)

# Derive feature importances
feature_importances = ____

# Plot the feature importances
____
plt.show()
Kodu Düzenle ve Çalıştır