Amany Abdelhalim阿曼尼·阿卜杜勒哈林

Follow跟随

Sep 18 九月18

Preprocessing Criteo Dataset for Prediction of Click Through Rate on Ads

预处理Criteo数据集以预测广告的点击率

In this post, I will be taking you through the steps that I performed to preprocess the Criteo Data set.

在这篇文章中,我将指导您完成预处理Criteo数据集的步骤。

Some Aspects to Consider when Preprocessing the Data预处理数据时应考虑的一些方面

Criteo data set is an online advertising dataset released by Criteo Labs. It contains feature values and click feedback for millions of display Ads, the data serves as a benchmark for clickthrough rate (CTR) prediction. Every Ad has features that describe the data. The data set has 40 attributes, the first attribute is the label where a value 1 represents that the Ad has been clicked on and a 0 represents it wasn’t clicked on. The attributes consist of 13 integer columns and 26 categorical columns.

Criteo数据集是Criteo Labs发布的在线广告数据集。 它包含数百万个展示广告的功能值和点击反馈,该数据可作为点击率(CTR)预测的基准。 每个广告都有描述数据的功能。 数据集具有40个属性,第一个属性是标签,其中值1表示已单击广告,而值0表示未单击广告。 该属性包含13个整数列和26个类别列。

I used PySpark on DataBricks notebooks to preprocess the data and train ML models.

我在DataBricks笔记本电脑上使用PySpark预处理数据并训练ML模型。

I started by reading the Critieo data in a data frame, the Criteo data was a TSV file tab separated and zipped (.gz). I saved the Criteo data set as a Parquet file, which saves the data in columnar format that allows the data to be handled mush faster than CSV format.

我从读取数据帧中的Critieo数据开始,Criteo数据是一个分隔并压缩(.gz)的TSV文件选项卡。 我将Criteo数据集保存为Parquet文件,该数据集以列格式保存数据,从而可以比CSV格式更快地处理数据。

One side note here to consider about Parquet files, that sometimes I noticed that overwriting an existing Parquet file could cause the data to be corrupted so I solved this situation by creating a new Parquet file rather than overwriting the old one.

这里有一个关于Parquet文件的注意事项,有时我注意到覆盖现有的Parquet文件可能会导致数据损坏,因此我通过创建一个新的Parquet文件而不是覆盖旧文件解决了这种情况。

I started by exploring the data in order to check whether it is balanced or not. The total number of records in the dataset is 45,840,617 records. I counted the records where the label equals 1 and where the labels equals 0 as follows:

我从探索数据开始,以检查数据是否平衡。 数据集中的记录总数为45,840,617条记录。 我计算了标签等于1且标签等于0的记录,如下所示:

I found that the number of clicked on Ads is only approximately 26% of the data while 74% of the data represents unclicked on Ads.

我发现,点击广告的次数仅占数据的26%,而其中74%的数据表示未点击广告。

The count of clicked on adds (1) versus unclicked on adds (0)点击添加次数(1)与未点击添加次数(0)的计数

The conclusion here is that the data is unbalanced. So I balanced the data by creating a new dataset that consists of all the Ad records that was clicked on added to it a random sample of the Ad records that was not clicked on, the size of that sample approximately equals the number of the Ad records that was clicked on.

这里的结论是数据不平衡。 因此,我通过创建一个新数据集来平衡数据,该数据集包含所有被点击的广告记录,并向其中添加了一个未被点击的广告记录的随机样本,该样本的大小大约等于广告记录的数量被点击。

So, 11,745,671 records were selected from the 34,095,179 records of not clicked on Ads.

因此,从未点击广告的34,095,179条记录中选择了11,745,671条记录。

The size of selected sample of the not clicked Ads is almost equal to the clicked on Ads所选未点击广告样本的大小几乎等于已点击广告的大小

I explored whether the columns had null values or not. I calculated the percentage of null values in each column. I found that out of the 39 coulmns, 15 coulmns had no null values and 24 columns had null values with different percentages.

我探讨了这些列是否具有空值。 我计算了每一列中空值的百分比。 我发现在39个库仑中,有15个库仑没有空值,而24列有空值且百分比不同。

Out of the 24 coulmns that had null values, I found that 2 columns (one integer coulmn and one categorical coulmn) had more than 75% null values which is a high percentage. I decided to drop those two columns. Now the dataset has the label column, and 37 other coulmns which are 12 integer columns and 25 categorical columns. Five other attributes (2 integer columns and 3 categorical columns) had more than 40% null values between 44% to 45%. I decided to convert those coulmns into boolean types True/False. I treated the null/zero values as False otherwise True.

在24个具有空值的库仑中,我发现2列(一个整数库仑和一个类别库仑)的空值超过75%,这是一个很高的百分比。 我决定删除这两列。 现在,数据集具有标签列和37个其他列,分别是12个整数列和25个分类列。 其他五个属性(2个整数列和3个类别列)的空值在44%到45%之间超过40%。 我决定将这些同语转换为布尔类型True / False。 我将null / zero值视为False,否则视为True。

For the columns that had null values (missing values) less than 40%, I did the following: for the integer coulmns, I calculated the mean for the clicked on Ad records and for the not clicked on Ad records. I replaced the null values in each column by the mean value based on whether the missing value exists in an Ad record that was clicked on or unclicked on. For the categorical columns, I calculated the mode for the clicked on Ad records and for the unclicked Ad records. I replaced the null values in each column by the mode value based on whether the missing value exists in an Ad record that was clicked on or unclicked on.

对于具有小于40%的空值(缺失值)的列,我执行了以下操作:对于整数列,我计算了广告记录上单击的和未点击广告记录的平均值。 根据缺少的值是否存在于被单击或未被单击的广告记录中,我将每列中的空值替换为平均值。 对于分类列,我计算了点击的广告记录和未点击的广告记录的模式。 根据缺少的值是否存在于单击或未单击的广告记录中,我用模式值替换了每列中的空值。

I also looked for outliers in the integer columns and replaced those values by the mean value. I Calculated the interquartile range (IQR) for the data in each coulmn. I then considered any value that is more than 1.5 x (IQR) plus the third quartile or less than the first quartile minus 1.5 x (IQR) as an outlier.

我还在整数列中查找异常值,并用平均值替换了这些值。 我计算了四分位间距(IQR) 对于每个库仑中的数据。 然后,我将任何大于1.5 x(IQR)加上第三个四分位数或小于第一个四分位数减去1.5 x(IQR)的值作为离群值。

Since the integer columns had continuous values with different ranges. I z-scored the values of the integer columns, then bucketized them.

由于整数列具有不同范围的连续值。 我对整数列的值进行了z计分,然后对它们进行了存储桶化。

The categorical columns in the dataset are anonymized strings, I transformed the values to indexes using the StringIndexr() transformer. Then I counted the distinct values for each categorical coulmn.

数据集中的分类列是匿名字符串,我使用StringIndexr()转换器将值转换为索引。 然后,我为每个分类库计数了不同的值。

Column name, distinct values count列名,不同值计数

I found that most of them have high dimensionality (e.g. 5,736,858 distinct values) and some considered low dimensional (e.g. 27 distinct values). I applied one hot encoding on the low dimensional categorical columns only. I combined the preprocessed features into one sparse vector using vector assembler.

我发现它们大多数具有较高的维数(例如5,736,858个不同的值),并且有一些被认为是低维的(例如27个不同的值)。 我仅对低维分类列应用了一种热编码。 我使用向量汇编器将预处理的特征组合到一个稀疏向量中。

For the steps described above, I needed to develop seven custom transformers. I developed transformers to perform the boolean transformation, to replace the null values in both the integer and categorical columns, to cap the outliers in the integer columns, scale the integer columns

对于上述步骤,我需要开发七个定制转换器。 我开发了转换器来执行布尔值转换,替换整数列和分类列中的空值,覆盖整数列中的离群值,缩放整数列

From pyspark.ml.feature, I used the built in Bucketizer() to bucketize the integer columns, the StringIndexr() to index the categorical columns with both low and high cardinality, the OneHotEncoder() to one hot encode the categorical columns with low cardinality and the VectorAssembler() to combine relevant columns into one column that I called “features”.

pyspark.ml.feature中,我使用内置的Bucketizer()对整数列进行存储桶化,使用StringIndexr()对基数低和高的类别列进行索引,将OneHotEncoder()进行热编码,对基数低的类别列进行热编码基数和VectorAssembler()将相关列合并为一列,我称之为“功能”。

I added all the transformers for all the columns to the stages of a pipeline and then I fitted and transformed the dataset using the pipeline.

我将所有列的所有转换器添加到管道的各个阶段,然后使用管道拟合并转换了数据集。

I arranged the data that will be used for training and testing ML models into a dataset that contains two columns; the label and the features column. I splited the data into a testing set (25%) and a training set (75%).

我将用于训练和测试ML模型的数据安排到一个包含两列的数据集中。 标签功能列。 我将数据分为测试集(25%)和训练集(75%)。

I trained three ML models; a logistic Regression, Random Forest and a Linear SVM Model on the training data set using the default parameter values for those models. I transformed the testing set using the three models and got label predictions. I calculated the accuracy of each model. The accuracy was approximately 70% (Linear SVM), 72% (logistic Regression) and 74% (Random Forest). By tunning the parameter values I was able to increase the models accuracy, for instance with the Random forest model I was able to get the accuracy to jump to 78% by setting the numTrees=50 and the maxDepth=20. You can always use something like grid search in sklearn which in Spark is referred to as ParamGridBuilder() to experiment couple of values for different parameters and get the best model that acheives the highest accuracy. You just need to ensure that you experiment with the right parameter values. For instance you need to ensure that the maxDepth can not go beyond 30, more than 30 is not supported yet. You also need to insure that your cluster configuration is done properly. I had set my cluster autopilot options to enable “auto scaling”, and I realized that when training my RF model I was getting errors indicating that some jobs has failed and from the error I got an indication that may be because the workers were auto scaling this could have been the problem where the jobs kept loosing some workers. Disabling the “auto scaling” option solved my problem. You should also make sure that the machines on your cluster have enough RAM. For instance, if you are training with a value more than 20 for the maxDepth you need machines with definitely more than 32 GB. You also need to expect that the training time will increase depending on the size of the data. For instance, training a random forest model with numTrees=50 and the maxDepth=20 took me more than 2 hours on a cluster of 16 machines, m5.2xlarge (32 GB, 8 cores).

我训练了三个ML模型; 使用这些模型的默认参数值在训练数据集上进行逻辑回归,随机森林和线性SVM模型。 我使用这三个模型转换了测试集,并获得了标签预测。 我计算了每个模型的准确性。 准确性约为70%(线性SVM),72%(逻辑回归)和74%(随机森林)。 通过调整参数值,我能够提高模型的准确性,例如,使用随机森林模型,通过设置numTrees = 50和maxDepth = 20,我能够使准确性提高到78%。 您始终可以在sklearn中使用诸如网格搜索之类的方法,在Spark中将其称为ParamGridBuilder()来对不同参数的几个值进行实验,并获得可实现最高准确性的最佳模型。 您只需要确保试验正确的参数值即可。 例如,您需要确保maxDepth不能超过30,尚不支持超过30。 您还需要确保集群配置正确完成。 我已经设置了群集自动驾驶仪选项以启用“自动缩放”,并且我意识到,在训练我的RF模型时,我收到指示某些作业失败的错误,并且从错误中我得到的指示可能是由于工人正在自动缩放这可能是工作继续失去一些工人的问题。 禁用“自动缩放”选项可以解决我的问题。 您还应确保群集上的计算机具有足够的RAM。 例如,如果您要为maxDepth训练大于20的值,则您需要的机器肯定大于32 GB。 您还需要期望训练时间会根据数据的大小而增加。 例如,在numTrees = 50和maxDepth = 20的情况下训练随机森林模型,使我在16台m5.2xlarge(32 GB,8核)机器上运行了2个多小时。

You can find my code here. I hope, you enjoyed my post and found it useful. In my next post, I will take you through the steps that I followed to use the trained models to make predictions on streaming data. You can find the next post here.

您可以在这里找到我的代码。 希望您喜欢我的帖子,并发现它很有用。 在我的下一篇文章中,我将带您完成遵循的步骤,以使用经过训练的模型对流数据进行预测。 您可以在这里找到下一篇文章。

翻译自: https://medium.com/@amany.m.abdelhalim/preprocessing-criteo-dataset-for-prediction-of-click-through-rate-on-ads-7dee096a2dd9


http://www.taodudu.cc/news/show-2320852.html

相关文章:

  • 穿山甲(巨量引擎)广告接入
  • Sklearn提供的常用数据集
  • 数据标签系统
  • 广告系统数据采集方法介绍
  • 广告投放-转化跟踪
  • 机器学习入门——线性回归预测广告投入数据集
  • 数据分析案例(4)京东数据分析项目
  • 激励视频广告 Android,腾讯社交联盟广告
  • 2019腾讯广告算法大赛题目理解与数据探索(含代码)
  • 获取GooglePlay下载来源广告数据统计接入
  • R实战之从头到尾分析广告数据集
  • 腾讯广点通DMP广告数据提交回传对接方法解析
  • 2019腾讯广告算法大赛之清洗广告数据集和用户数据集
  • 微信广告数据源创建查询与上报-PHP
  • Facebook广告投放数据分析
  • Google广告数据分析与优化总结
  • 23000字,讲清信息流广告数据分析。
  • 广告数据定量分析:第一章——广告优化中的统计学
  • 亚马逊 站内广告数据分析
  • 淘宝广告数据分析实战!(附代码和100W数据源)
  • 广告数据分析一
  • 【图片】 3D打印的一些小东西 暗黑
  • 3d打印英语文献_3D打印NiTi形状记忆合金管的扭转性能研究
  • 3d打印零件精度的影响
  • FDM3D打印技术原理简析
  • 3d打印技术是计算机在哪一方面的应用,3D打印技术的应用范围 3D打印技术的应用领域有哪些?...
  • 3D打印钢网?
  • 3D打印技术到底有多强大?
  • 3D打印的应用范围
  • 3d打印计算机设计打孔操作,干货:3D打印,建模时你需要注意这10个技巧

预处理criteo数据集以预测广告的点击率相关推荐

  1. criteo 点击率预估_预处理criteo数据集以预测广告的点击率

    criteo 点击率预估 Amany Abdelhalim阿曼尼·阿卜杜勒哈林 Follow跟随 Sep 18 九月18 Preprocessing Criteo Dataset for Predic ...

  2. 阿里妈妈牟娜:定向广告新一代点击率预估主模型——深度兴趣演化网络

    分享嘉宾:牟娜 阿里巴巴 高级算法工程师 编辑整理:孙锴 内容来源:DataFun AI Talk<定向广告新一代点击率预估主模型--深度兴趣演化网络> 出品社区:DataFun 导读: ...

  3. 小程序流量主申请,如何增加小程序广告的点击率?

    小程序开发者千千万,真正赚$的却没有多少,尤其是像我这种个人业余开发者.不过,有想法不去实现一把总会觉得心有不甘,送大家一句话:为道者,虽千万人吾往矣! 相信大多数小程序开发者和我一样,开发小程序并不 ...

  4. 分享Spark MLlib训练的广告点击率预测模型

    2015年,全球互联网广告营收接近600亿美元,比2014年增长了近20%.多家互联网巨头都依赖于广告营收,如谷歌,百度,Facebook,互联网新贵们也都开始试水广告业,如Snapchat, Pin ...

  5. 广告点击率预测_精品案例|在线广告点击率预测

    目录 数据说明 数据查看 数据预处理   3.1 处理非数值特征 初步建立模型查看效果 探索性分析和特征工程   5.1 特征分布可视化   5.2 处理取值不均匀特征   5.3 特征相关性 模型训 ...

  6. 使用python进行广告点击率的预测

    当前在线广告服务中,广告的点击率(CTR)是评估广告效果的一个非常重要的指标. 因此,点击率预测系统是必不可少的,并广泛用于赞助搜索和实时出价.那么如何计算广告的点击率呢? 广告的点击率 = 广告点击 ...

  7. 点击率预测的贝叶斯平滑

    文章目录 背景 贝叶斯平滑 点击率贝叶斯平滑的假设 点击率的极大似然估计 点击率的贝叶斯估计 平滑系数的计算 贝叶斯平滑因子的工程实践 矩估计 工程实践 非二项分布的贝叶斯平滑 背景 电商领域中经常需 ...

  8. 互联网广告综述之点击率特征工程

    2019独角兽企业重金招聘Python工程师标准>>> 互联网广告综述之点击率特征工程 声明: 1)该博文是整理自网上很大牛和专家所无私奉献的资料的.具体引用的资料请看参考文献.具体 ...

  9. 【总结】广告点击率预估中的特征选择

    互联网广告综述之点击率特征工程 一.互联网广告特征工程 博文<互联网广告综述之点击率系统>论述了互联网广告的点击率系统,可以看到,其中的logistic regression模型是比较简单 ...

  10. 计算广告(一)【Ad Click Prediction: a View from the Trenches】工程实践视角下的广告点击率预估

    计算广告(一)Ad Click Prediction: a View from the Trenches --工程实践视角下的广告点击率预估 这是谷歌发表于KDD2013的一篇文章,从年份来看,已经有 ...

最新文章

  1. 论文翻译_做论文翻译需要知道哪些翻译技巧?知行翻译:这3个技巧
  2. 湖南网络推广教大家如何“挽回”网站被降权的排名和权重?
  3. 选购商用计算机任务书,计算机网络综合实习任务书-.doc
  4. admob 服务器验证_AdMob服务器注册广告请求,但Ad对象包含“必须声明AdActivity”错误...
  5. websocket后台推送数据
  6. Fiori应用里如何给客户主数据维护图片
  7. Good Number Gym - 102769G 2020年CCPC秦皇岛分站赛
  8. QT:QObject 简单介绍
  9. android .a文件报毒,游戏开始文件,小A报毒!
  10. Win7下修改Hosts文件
  11. Mac硬件温度管理软件TG Pro
  12. 卸载Symantec——无需密码,卸载干净,Windows
  13. 好看又实用的英文字体
  14. cdr添加节点快捷键_cdr怎么添加节点 在CDR X8怎么给曲线添加节点图文教程
  15. 新浪微博开放平台开发-android客户端(1)
  16. 【英语】 英语的重音怎么读
  17. screen 命令详解
  18. 疾病研究:DMD及BMD的机理和临床表现(译稿)
  19. 一键解锁iPhone屏幕密码
  20. 哈工大硕士生实现 11 种数据降维算法,代码已开源!

热门文章

  1. HS0038红外接收模块遇到的问题
  2. 【测试】转行软件测试没有项目经历怎么办
  3. ad中那个快捷键是重复上一部_PPT中十大快捷键
  4. 农夫山泉启示录:零售价2块钱的水,水值2分钱【姜太公公】
  5. 求长方形和正方形的周长
  6. 家庭生涯妙招,必定要看哦
  7. 我的世界基java版刷怪机制_我的世界为什么自己的刷怪塔效率低下原因分析
  8. 关于华为2019全联接大会,精华内容都在这里!
  9. 理查德•弗曼学习法思维导图-程序猿学习法
  10. 企业物流管理与最新IT技术