特征探索
继续使用同一份 Avazu 数据集,您将探索 device_type 和 banner_pos 的取值分布,并查看基于这些取值的 CTR(点击率)有何差异。
以 DataFrame 形式加载的示例数据为 df。您在上一个练习中创建的变量 X 和 y 已在工作区中可用。pandas 也已以 pd 名称在您的工作区中可用。
本练习是课程的一部分
用 Python 预测 CTR 的机器学习实战
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Distribution of values for device type
print("Distribution of device type: ")
print(X.device_type.____()/len(X))
# Sample CTR by device type
print("CTR by device type: ")
print(df.____('device_type')['click'].____/len(y))