1. Learn
  2. /
  3. Courses
  4. /
  5. Predicting CTR with Machine Learning in Python

Exercise

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.

Instructions

100 XP
  • 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().