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

Visualizing a linear regression model

Now you have built your linear regression model and trained it using all available observations, you can visualize how well the model fits the data. This allows you to interpret the relationship between radio advertising expenditure and sales values.

The variables X, an array of radio values, y, an array of sales values, and predictions, an array of the model's predicted values for y given X, have all been preloaded for you from the previous exercise.

Bu egzersiz

Supervised Learning with scikit-learn

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

Egzersiz talimatları

  • Import matplotlib.pyplot as plt.
  • Create a scatter plot visualizing y against X, with observations in blue.
  • Draw a red line plot displaying the predictions against X.
  • Display the plot.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Import matplotlib.pyplot
import ____.____ as ____

# Create scatter plot
plt.scatter(____, ____, color="____")

# Create line plot
plt.plot(____, ____, color="____")
plt.xlabel("Radio Expenditure ($)")
plt.ylabel("Sales ($)")

# Display the plot
plt.____()
Kodu Düzenle ve Çalıştır