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

Computing feature impact with linear regression

As a data scientist at an insurance company, your task is to build and explain a linear regression model that estimates insurance charges based on features like age, BMI, and smoking status by analyzing the model's coefficients to determine the impact of each feature on the predictions.

matplotlib.pyplot has been imported as plt along with MinMaxScaler. 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ı

  • Normalize the training data X_train.
  • Fit the linear regression model to the standardized training data.
  • Extract the coefficients from the model.
  • Plot the coefficients for the given feature_names.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Standardize the training data
scaler = MinMaxScaler()
X_train_scaled = ____
model = LinearRegression()

# Fit the model
____

# Derive coefficients
coefficients = ____
feature_names = X_train.columns

# Plot coefficients
plt.bar(____, ____)
plt.show()
Kodu Düzenle ve Çalıştır