Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Oneflow-Inc
OneFlow-Benchmark
提交
395c28f5
O
OneFlow-Benchmark
项目概览
Oneflow-Inc
/
OneFlow-Benchmark
上一次同步 2 年多
通知
1
Star
92
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
OneFlow-Benchmark
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
395c28f5
编写于
6月 15, 2021
作者:
S
ShawnXuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update how_to_make_hf_dataset.md
上级
d1275e63
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
2 addition
and
7 deletion
+2
-7
ClickThroughRate/WideDeepLearning/how_to_make_hf_dataset.md
ClickThroughRate/WideDeepLearning/how_to_make_hf_dataset.md
+2
-7
未找到文件。
ClickThroughRate/WideDeepLearning/how_to_make_hf_dataset.md
浏览文件 @
395c28f5
# How to Make High Frequency Dataset for OneFlow-WDL
[
**how_to_make_ofrecord_for_wdl**
](
https://github.com/Oneflow-Inc/OneFlow-Benchmark/blob/master/ClickThroughRate/WideDeepLearning/how_to_make_ofrecord_for_wdl.md
)
一文中介绍了如何利用spark制作OneFlow-WDL使用的ofrecord数据集,GPU&CPU混合embedding的实践中
,这个数据集就不好用了,主要原因是没有按照词频排序,所以需要制作新的数据集。
本文将持续上文中的套路,介绍一下如何制作按照词频排序的数据集。
[
**how_to_make_ofrecord_for_wdl**
](
https://github.com/Oneflow-Inc/OneFlow-Benchmark/blob/master/ClickThroughRate/WideDeepLearning/how_to_make_ofrecord_for_wdl.md
)
一文中介绍了如何利用spark制作OneFlow-WDL使用的ofrecord数据集,GPU&CPU混合embedding的实践中
需要把特征根据词频从大到小排序,
本文将持续上文中的套路,介绍一下如何制作按照词频排序的数据集。
## 数据集及预处理
...
...
@@ -53,14 +53,12 @@ Files.createDirectories(Paths.get(tmp_dir))
```
scala
// load input file
var
input
=
spark
.
read
.
options
(
Map
(
"delimiter"
->
"\t"
)).
csv
(
"file:///DATA/disk1/xuan/train.shuf.bak"
)
// var input = spark.read.options(Map("delimiter"->"\t")).csv("file:///DATA/disk1/xuan/train.shuf.txt")
// rename columns [label, I1,...,I13, C1,...,C26]
val
NUM_INTEGER_COLUMNS
=
13
val
NUM_CATEGORICAL_COLUMNS
=
26
// val integer_cols = (1 to NUM_INTEGER_COLUMNS).map{id=>s"I$id"}
val
integer_cols
=
(
1
to
NUM_INTEGER_COLUMNS
).
map
{
id
=>
$
"I$id"
}
// note
val
integer_cols
=
(
1
to
NUM_INTEGER_COLUMNS
).
map
{
id
=>
$
"I$id"
}
val
categorical_cols
=
(
1
to
NUM_CATEGORICAL_COLUMNS
).
map
{
id
=>
s
"C$id"
}
val
feature_cols
=
integer_cols
.
map
{
c
=>
c
.
toString
}
++
categorical_cols
val
all_cols
=
(
Seq
(
s
"labels"
)
++
feature_cols
)
...
...
@@ -133,7 +131,6 @@ for(column_name <- integer_cols) {
}
else
{
scaledDf
=
indexedDf
.
withColumn
(
col_name
,
col
(
col_index
)
+
lit
(
1
))
// trick: reuse col_name
.
select
(
"id"
,
col_name
)
//.withColumn(col_name, col(col_index).cast(IntegerType))
}
val
col_dir
=
tmp_dir
++
"/"
++
col_name
scaledDf
=
scaledDf
.
withColumn
(
col_name
,
getItem
(
column_name
,
lit
(
0
)))
...
...
@@ -233,8 +230,6 @@ for(cross_pair <- cross_pairs) {
val
df_col
=
spark
.
read
.
parquet
(
tmp_dir
++
"/"
++
cross_pair
)
df
=
df
.
join
(
df_col
,
Seq
(
"id"
))
}
// df.select("C1_C2", "C3_C4").createOrReplaceTempView("f")
// df.select(cross_pairs.map{id=>col(id)}:_*).createOrReplaceTempView("f")
df
.
select
(
cross_pairs
map
col
:
_
*
).
createOrReplaceTempView
(
"f"
)
val
orderedValues
=
spark
.
sql
(
"select cid, count(*) as cnt from (select explode( array("
+
cross_pairs
.
mkString
(
","
)
+
") ) as cid from f) group by cid "
).
filter
(
"cnt>=6"
).
orderBy
(
$
"cnt"
.
desc
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录