注:本试用是在win10下安装试用
一、导入items成功:
gorse import-items C:\Users\zhouxiujue/.gorse/gorse.db D:\golang\dataset\ml-100k\u.item
2020/04/09 11:45:04 database status: 0 feedback, 0 items
2020/04/09 11:45:04 import items from D:\golang\dataset\ml-100k\u.item
2020/04/09 11:45:04 database status: 0 feedback, 1682 items
2020/04/09 11:45:04 items are imported successfully! (31.2878ms)
二、导入feedback不成功:
gorse import-feedback C:\Users\zhouxiujue\.gorse\gorse.db C:\Users\zhouxiujue\.gorse\dataset\ml-100k\u.data --sep $'\t'
2020/04/09 13:55:37 database status: 0 feedback, 1682 items
2020/04/09 13:55:37 import feedback from C:\Users\zhouxiujue\.gorse\dataset\ml-100k\u.data
2020/04/09 13:55:37 database status: 0 feedback, 1682 items
2020/04/09 13:55:37 feedback are imported successfully! (22.1404ms)
后从别的文章中得到启发,不能用单引号,改为双引号:
gorse import-feedback C:\Users\zhouxiujue\.gorse\gorse.db C:\Users\zhouxiujue\.gorse\dataset\ml-100k\u.data --sep $"\t"
仍然不成功,推测问题出在分隔符的转义符的写法不准确,把分隔符改为逗号就可以了。
Tab键用 --sep $"\t" 在windows的dos下可能不准确。如果有人知道麻烦留言!!谢谢!
三、调接口导入:
curl -X PUT -H 'Content-Type: application/json' 127.0.0.1:8080/items -d '[{"ItemId":"2048","Timestamp":"2010-1-1"},{"ItemId":"2049","Timestamp":"2011-1-1"},{"ItemId":"2050","Timestamp":"2012-1-1"}]'
不成功!,原因还是单引号。
改为双引号:
curl -X PUT -H "Content-Type: application/json" 127.0.0.1:8080/feedback -d "[{\"UserId\":\"2048\",\"ItemId\":\"1000\",\"Rating\":3},{\"UserId\":\"2049\",\"ItemId\":\"1000\",\"Rating\":3}]"
导入成功:
{
"ItemsBefore": 1682,
"ItemsAfter": 1683,
"UsersBefore": 1,
"UsersAfter": 2,
"FeedbackBefore": 0,
"FeedbackAfter": 2
}
四、启动gorse的server,配置文件在example中有一份现成的可以用
gorse serve -c D:\dev\gopath\src\github.com\zhenghaoz\gorse\example\file_config\config.toml
注意,你需要先导入feedback和items才能启动服务。
在IE中访问:
http://127.0.0.1:8080/recommends/13?number=10
有返回:
[
{
"ItemId": "988",
"Popularity": 86,
"Timestamp": "0001-01-01T00:00:00Z",
"Score": 1
},
{
"ItemId": "259",
"Popularity": 162,
"Timestamp": "0001-01-01T00:00:00Z",
"Score": 0.9783490222851946
},
{
"ItemId": "245",
"Popularity": 240,
"Timestamp": "0001-01-01T00:00:00Z",
"Score": 0.8745238818109914
},
{
"ItemId": "304",
"Popularity": 149,
"Timestamp": "0001-01-01T00:00:00Z",
"Score": 0.8301400379197285
},
{
"ItemId": "325",
"Popularity": 128,
"Timestamp": "0001-01-01T00:00:00Z",
"Score": 0.8140271102494833
},
{
"ItemId": "496",
"Popularity": 231,
"Timestamp": "0001-01-01T00:00:00Z",
"Score": 0.8074109883626155
},
{
"ItemId": "257",
"Popularity": 303,
"Timestamp": "0001-01-01T00:00:00Z",
"Score": 0.7536048916776367
},
{
"ItemId": "266",
"Popularity": 35,
"Timestamp": "0001-01-01T00:00:00Z",
"Score": 0.7516811220131554
},
{
"ItemId": "134",
"Popularity": 198,
"Timestamp": "0001-01-01T00:00:00Z",
"Score": 0.7496362849649536
},
{
"ItemId": "948",
"Popularity": 48,
"Timestamp": "0001-01-01T00:00:00Z",
"Score": 0.6596478258360672
}
]
2万+

被折叠的 条评论
为什么被折叠?



