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

Instantiate the model

In the following set of exercises, you'll diagnose the bias and variance problems of a regression tree. The regression tree you'll define in this exercise will be used to predict the mpg consumption of cars from the auto dataset using all available features.

We have already processed the data and loaded the features matrix X and the array y in your workspace. In addition, the DecisionTreeRegressor class was imported from sklearn.tree.

Bu egzersiz

Machine Learning with Tree-Based Models in Python

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

Egzersiz talimatları

  • Import train_test_split from sklearn.model_selection.
  • Split the data into 70% train and 30% test.
  • Instantiate a DecisionTreeRegressor with max depth 4 and min_samples_leaf set to 0.26.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Import train_test_split from sklearn.model_selection
____

# Set SEED for reproducibility
SEED = 1

# Split the data into 70% train and 30% test
X_train, X_test, y_train, y_test = ____(____, ____, test_size=____, random_state=SEED)

# Instantiate a DecisionTreeRegressor dt
dt = ____(____=____, ____=____, random_state=SEED)
Kodu Düzenle ve Çalıştır