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

Building a linear regression model

Now you have created your feature and target arrays, you will train a linear regression model on all feature and target values.

As the goal is to assess the relationship between the feature and target values there is no need to split the data into training and test sets.

X and y have been preloaded for you as follows:

y = sales_df["sales"].values
X = sales_df["radio"].values.reshape(-1, 1)

Bu egzersiz

Supervised Learning with scikit-learn

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

Egzersiz talimatları

  • Import LinearRegression.
  • Instantiate a linear regression model.
  • Predict sales values using X, storing as predictions.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Import LinearRegression
from ____.____ import ____

# Create the model
reg = ____()

# Fit the model to the data
____

# Make predictions
predictions = ____

print(predictions[:5])
Kodu Düzenle ve Çalıştır