Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
book
提交
a6ed66b9
B
book
项目概览
PaddlePaddle
/
book
通知
16
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
40
列表
看板
标记
里程碑
合并请求
37
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
B
book
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
40
Issue
40
列表
看板
标记
里程碑
合并请求
37
合并请求
37
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a6ed66b9
编写于
6月 06, 2018
作者:
N
Nicky
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Compare predict and actual data result
上级
34b152f7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
18 addition
and
8 deletion
+18
-8
05.recommender_system/README.md
05.recommender_system/README.md
+9
-4
05.recommender_system/index.html
05.recommender_system/index.html
+9
-4
未找到文件。
05.recommender_system/README.md
浏览文件 @
a6ed66b9
...
...
@@ -452,15 +452,18 @@ Use create_lod_tensor(data, lod, place) API to generate LoD Tensor, where `data`
For example, data = [[10, 2, 3], [2, 3]] means that it contains two sequences of indices, of length 3 and 2, respectively.
Correspondingly, lod = [[3, 2]] contains one level of detail info, indicating that
`data`
consists of two sequences of length 3 and 2.
In this infer example, we try to predict rating of movie 'Hunchback of Notre Dame' from user id 1 info.
```
python
infer_movie_id
=
783
infer_movie_name
=
paddle
.
dataset
.
movielens
.
movie_info
()[
infer_movie_id
].
title
user_id
=
fluid
.
create_lod_tensor
([[
1
]],
[[
1
]],
place
)
gender_id
=
fluid
.
create_lod_tensor
([[
1
]],
[[
1
]],
place
)
age_id
=
fluid
.
create_lod_tensor
([[
0
]],
[[
1
]],
place
)
job_id
=
fluid
.
create_lod_tensor
([[
10
]],
[[
1
]],
place
)
movie_id
=
fluid
.
create_lod_tensor
([[
783
]],
[[
1
]],
place
)
category_id
=
fluid
.
create_lod_tensor
([[
10
,
8
,
9
]],
[[
3
]],
place
)
movie_id
=
fluid
.
create_lod_tensor
([[
783
]],
[[
1
]],
place
)
# Hunchback of Notre Dame
category_id
=
fluid
.
create_lod_tensor
([[
10
,
8
,
9
]],
[[
3
]],
place
)
# Animation, Children's, Musical
movie_title
=
fluid
.
create_lod_tensor
([[
1069
,
4140
,
2923
,
710
,
988
]],
[[
5
]],
place
)
place
)
# 'hunchback','of','notre','dame','the'
```
### Infer
...
...
@@ -480,7 +483,9 @@ results = inferencer.infer(
},
return_numpy
=
False
)
print
(
"infer results: "
,
np
.
array
(
results
[
0
]))
predict_rating
=
np
.
array
(
results
[
0
])
print
(
"Predict Rating of user id 1 on movie
\"
"
+
infer_movie_name
+
"
\"
is "
+
str
(
predict_rating
[
0
][
0
]))
print
(
"Actual Rating of user id 1 on movie
\"
"
+
infer_movie_name
+
"
\"
is 4."
)
```
...
...
05.recommender_system/index.html
浏览文件 @
a6ed66b9
...
...
@@ -494,15 +494,18 @@ Use create_lod_tensor(data, lod, place) API to generate LoD Tensor, where `data`
For
example
,
data =
[[10,
2,
3],
[2,
3]]
means
that
it
contains
two
sequences
of
indices
,
of
length
3
and
2,
respectively.
Correspondingly
,
lod =
[[3,
2]]
contains
one
level
of
detail
info
,
indicating
that
`
data
`
consists
of
two
sequences
of
length
3
and
2.
In
this
infer
example
,
we
try
to
predict
rating
of
movie
'
Hunchback
of
Notre
Dame
'
from
user
id
1
info.
```
python
infer_movie_id =
783
infer_movie_name =
paddle.dataset.movielens.movie_info()[infer_movie_id].title
user_id =
fluid.create_lod_tensor([[1]],
[[1]],
place
)
gender_id =
fluid.create_lod_tensor([[1]],
[[1]],
place
)
age_id =
fluid.create_lod_tensor([[0]],
[[1]],
place
)
job_id =
fluid.create_lod_tensor([[10]],
[[1]],
place
)
movie_id =
fluid.create_lod_tensor([[783]],
[[1]],
place
)
category_id =
fluid.create_lod_tensor([[10,
8,
9]],
[[3]],
place
)
movie_id =
fluid.create_lod_tensor([[783]],
[[1]],
place
)
#
Hunchback
of
Notre
Dame
category_id =
fluid.create_lod_tensor([[10,
8,
9]],
[[3]],
place
)
#
Animation
,
Children
'
s
,
Musical
movie_title =
fluid.create_lod_tensor([[1069,
4140,
2923,
710,
988]],
[[5]],
place
)
place
)
#
'
hunchback
','
of
','
notre
','
dame
','
the
'
```
###
Infer
...
...
@@ -522,7 +525,9 @@ results = inferencer.infer(
},
return_numpy=
False)
print
("
infer
results:
",
np.array
(
results
[0]))
predict_rating =
np.array(results[0])
print
("
Predict
Rating
of
user
id
1
on
movie
\""
+
infer_movie_name
+
"\"
is
"
+
str
(
predict_rating
[0][0]))
print
("
Actual
Rating
of
user
id
1
on
movie
\""
+
infer_movie_name
+
"\"
is
4.")
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录