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

Creating features

In this chapter, you will work with a dataset called sales_df, which contains information on advertising campaign expenditure across different media types, and the number of dollars generated in sales for the respective campaign. The dataset has been preloaded for you. Here are the first two rows:

     tv        radio      social_media    sales
1    13000.0   9237.76    2409.57         46677.90
2    41000.0   15886.45   2913.41         150177.83

You will use the advertising expenditure as features to predict sales values, initially working with the "radio" column. However, before you make any predictions you will need to create the feature and target arrays, reshaping them to the correct format for scikit-learn.

Bu egzersiz

Supervised Learning with scikit-learn

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

Egzersiz talimatları

  • Create X, an array of the values from the sales_df DataFrame's "radio" column.
  • Create y, an array of the values from the sales_df DataFrame's "sales" column.
  • Reshape X into a two-dimensional NumPy array.
  • Print the shape of X and y.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

import numpy as np

# Create X from the radio column's values
X = ____

# Create y from the sales column's values
y = ____

# Reshape X
X = ____

# Check the shape of the features and targets
print(____)
Kodu Düzenle ve Çalıştır