探索性数据分析

用 Python 预测 CTR 的机器学习实战

Kevin Huo

Instructor

深入查看特征

print(df.columns)
['id', 'click', 'hour', 'C1', ... ]
print(df.dtypes)
id                  object
click                int64
...
  • int:整数:12 等。
  • float:小数:3.024.56 等。
  • object:字符串:"hello""world" 等。
  • datetime:日期时间:2018-01-01 等。
df.select_dtypes(
  include=['int', 'float'])
click                int64
...
用 Python 预测 CTR 的机器学习实战

缺失数据

df.info()
数据列(共 24 列):
id            50000 非空 object
df['id'].isnull()
[False, False, False, False, ... ]
df.isnull().sum(axis = 0)
dtype: object
id                  0
...
df.isnull().sum(axis = 0).sum()
0
用 Python 预测 CTR 的机器学习实战

查看分布

df.groupby(['search_engine_type', 
            'click']).size()
search_engine_type    click
1002          0          940
              1          240
                   ...
df.groupby(['search_engine_type',
            'click']).size().unstack()
click                  0     1
search_engine_type               
1002                 940   240
               ...
用 Python 预测 CTR 的机器学习实战

按 CTR 分解

df.reset_index()
click  search_engine_type      0     1
                     1002    940   240
df = df.rename(columns = {0: 'non_clicks'})
click  search_engine_type  non_clicks  clicks
                     1002         940     240
用 Python 预测 CTR 的机器学习实战

Ayo berlatih!

用 Python 预测 CTR 的机器学习实战

Preparing Video For Download...