НачатьНачать бесплатно

Beginning steps

In this exercise, you will get a quick look at sample data using some basic DataFrame operations and taking a first look at CTR. The data comes from Avazu, a leading global advertising platform and captures user interactions on various device types for different websites and apps.

The target variable will be in the click column. The hour is in a YYMMDDHH format, and there are a few integer columns: device_type for the type of device, banner_pos for the position of a banner ad (also known as a display ad), etc. There will also be other variables discussed in later chapters.

Sample data in DataFrame form is loaded as df.pandas as pd are available in your workspace.

Это упражнение является частью курса

Predicting CTR with Machine Learning in Python

Посмотреть курс

Инструкции к упражнению

  • Define variable X using .isin(). X will be all of the columns except for the click column.
  • Define variable y, which can be accessed using df.click.
  • Print out the proportion of rows of y that are a 1 - this represents the sample CTR, using y.sum().

Интерактивное практическое упражнение

Попробуйте выполнить это упражнение, дополнив этот пример кода.

# Look at basics of Dataframe 
print(df.head(5))
print(df.columns)

# Define X and y
X = df.____[:, ~df.columns.____(['click'])]
y = df.____

# Sample CTR
print("Sample CTR :\n", 
      y.____/len(y))
Редактировать и запускать код