内容简介:PredictionIO 是一个用Scala编写的开源机器学习服务器应用,可以帮助你方便地使用RESTFul API搭建推荐引擎。 PredictionIO的核心使用的是一个可伸缩的机器学习库,基于Spark一个完整的端到端Pipeline,让使用者可以非常简单的从零开始搭建一个推荐系统。 "PredictionIO 是由三个元件所组成:官方有提供快速的一键安装方法,当然也可以手动安装。
PredictionIO 是一个用Scala编写的开源机器学习服务器应用,可以帮助你方便地使用RESTFul API搭建推荐引擎。 PredictionIO的核心使用的是一个可伸缩的机器学习库,基于Spark一个完整的端到端Pipeline,让使用者可以非常简单的从零开始搭建一个推荐系统。 "
PredictionIO 是由三个元件所组成:
- PredictionIO platform
- Event Server: 收集来自应用程式的资料,可以是即时也可以定时。
- Engine: 训练模型,并且将结果以 Restful API 提供查询。
Install
官方有提供快速的一键安装方法,当然也可以手动安装。
$ bash -c "$(curl -s https://install.prediction.io/install.sh)" $ PATH=$PATH:/home/yourname/PredictionIO/bin; export PATH 复制代码
透过以下指定可以检查是否安装成功,会回传每一种套件所连接的状况
$ pio status ### Return: [INFO] [Console$] Inspecting PredictionIO... [INFO] [Console$] PredictionIO 0.9.6 is installed at ... [INFO] [Console$] Inspecting Apache Spark... [INFO] [Console$] Apache Spark is installed at ... [INFO] [Console$] Apache Spark 1.6.0 detected ... [INFO] [Console$] Inspecting storage backend connections... [INFO] [Storage$] Verifying Meta Data Backend (Source: MYSQL)... [INFO] [Storage$] Verifying Model Data Backend (Source: MYSQL)... [INFO] [Storage$] Verifying Event Data Backend (Source: MYSQL)... [INFO] [Storage$] Test writing to Event Store (App Id 0)... [INFO] [Console$] (sleeping 5 seconds for all messages to show up...) [INFO] [Console$] Your system is all ready to go. 复制代码
Quick Start
Step 1. Run PredictionIO
先执行 PredictionIO 主程式,针对不同的储存器,有不同的执行方法。
$ pio eventserver & # If you are using PostgreSQL or MySQL, run the following to start PredictionIO Event Server or $ pio-start-all # If instead you are running HBase and Elasticsearch, run the following to start all PredictionIO Event Server, HBase, and Elasticsearch 复制代码
Step 2. Create a new Engine from an Engine Template
选择Engine Templates 一个适合的 Engine。
$ pio template get <template-repo-path> <your-app-directory> $ cd MyRecommendation 复制代码
可以从Engine Templates 选择,也可以自定义,在这边我们使用 Universal Recommender
作为范例。
Step 3. Generate an App ID and Access Key
执行指定从 Engine 产生一个 APP 并取得对应的 Key。
$ pio app new MyRecommendation ### Return: [INFO] [App$] Initialized Event Store for this app ID: 1. [INFO] [App$] Created new app: [INFO] [App$] Name: MyRecommendation [INFO] [App$] ID: 1 [INFO] [App$] Access Key: ... $ pio app list ### Return: [INFO] [App$] Name | ID | Access Key | Allowed Event(s) [INFO] [App$] MyRecommendation | 1 | ... | (all) [INFO] [App$] Finished listing 1 app(s). 复制代码
Step 4. Collecting Data
接着要汇入资料,最基本的推荐演算法(Cooperative Filtering, CF)格式支元: user
- action
- item
三种元素。使用 data/import_eventserver.py
可以将符合格式的资料汇入资料库。
$ curl <sample_data> --create-dirs -o data/<sample_data> $ python data/import_eventserver.py --access_key <access-key> 复制代码
... 0::2::3 0::3::1 3::9::4 6::9::1 ... 复制代码
Step 5. Deploy the Engine as a Service
在部署应用程式之前,先在 Engine.json 中设定基础资料,像是 appName 或是演算法要运行几次之类的。
... "datasource": { "params" : { "appName": MyRecommendation # make sure the appName parameter match your App Name } }, ... 复制代码
部署系统到 Web Service 时,过程中分成三个步骤: pio build -> pio train -> pio deploy Building 负责准备 Spark 的基础环境及资料准备。 Training 负责执行演算法建模。 Deployment 则是将结果运行在 Web Service 上,并以 Restful API 开放。
- Bulid and Training the Predictive Model
$ pio build ### Return: [INFO] [Console$] Your engine is ready for training. $ pio train ### Return: [INFO] [CoreWorkflow$] Training completed successfully. $ pio deploy ### Return: [INFO] [HttpListener] Bound to /0.0.0.0:8000 [INFO] [MasterActor] Bind successful. Ready to serve. 复制代码
Step 6. Use the Engine
然后就是执行了,预设会开在 port 8000,参数输入 使用者
即要推荐的 商品数量
。
$ curl -H "Content-Type: application/json" \ -d '{ "user": "1", "num": 4 }' https://localhost:8000/queries.json ### Retnrn: { "itemScores":[ {"item":"22","score":4.072304374729956}, {"item":"62","score":4.058482414005789}, {"item":"75","score":4.046063009943821}, {"item":"68","score":3.8153661512945325} ] } 复制代码
以上所述就是小编给大家介绍的《PredictionIO:开源的推荐系统》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- 开源推荐 | CoDo开源一站式DevOps平台
- 一周 GitHub 开源项目推荐
- 开源年会 COSCon'18 之开源硬件论坛 | 深圳湾推荐
- 阿里淘系优质开源项目推荐
- GitHub关键字扫描开源工具推荐
- Facebook开源深度学习推荐模型DLRM
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Compilers
Alfred V. Aho、Monica S. Lam、Ravi Sethi、Jeffrey D. Ullman / Addison Wesley / 2006-9-10 / USD 186.80
This book provides the foundation for understanding the theory and pracitce of compilers. Revised and updated, it reflects the current state of compilation. Every chapter has been completely revised ......一起来看看 《Compilers》 这本书的介绍吧!