项目作者: apache

项目描述 :
PredictionIO E-Commerce Recommendation Engine Template (Scala-based parallelized engine)
高级语言: Scala
项目地址: git://github.com/apache/predictionio-template-ecom-recommender.git
创建时间: 2015-02-17T00:47:57Z
项目社区:https://github.com/apache/predictionio-template-ecom-recommender

开源协议:Apache License 2.0

下载


E-Commerce Recommendation Template

Documentation

Please refer to
https://predictionio.apache.org/templates/ecommercerecommendation/quickstart/

Versions

v0.14.0

Update for Apache PredictionIO 0.14.0

v0.13.0

Update for Apache PredictionIO 0.13.0

v0.12.0-incubating

  • Bump version number to track PredictionIO version
  • Sets default build targets according to PredictionIO
  • Fix warnings

v0.11.0-incubating

  • Bump version number to track PredictionIO version
  • Rename Scala package name
  • Update SBT version

v0.5.0

  • Update for Apache PredictionIO 0.10.0-incubating

v0.4.0

  • Change from ALSAlgorithm.scala to ECommAlgorithm.scala

    • return popular bought items when no information is found for the user.
    • add “similarEvents” parameter for configuration what user-to-item events are used for finding similar items
    • re-structure the Algorithm code for easier customization and testing
  • add some unit tests for testing code that may be customized

v0.3.1

  • use INVALID_APP_NAME as default appName in engine.json

v0.3.0

  • update for PredictionIO 0.9.2, including:

    • use new PEventStore and LEventStore API
    • use appName in DataSource and Algorithm parameters

v0.2.0

  • update build.sbt and template.json for PredictionIO 0.9.2

v0.1.1

  • update for PredictionIO 0.9.0

v0.1.0

  • initial version

Development Notes

import sample data

  1. $ python data/import_eventserver.py --access_key <your_access_key>

query

normal:

  1. $ curl -H "Content-Type: application/json" \
  2. -d '{
  3. "user" : "u1",
  4. "num" : 10 }' \
  5. http://localhost:8000/queries.json \
  6. -w %{time_connect}:%{time_starttransfer}:%{time_total}
  1. $ curl -H "Content-Type: application/json" \
  2. -d '{
  3. "user" : "u1",
  4. "num": 10,
  5. "categories" : ["c4", "c3"]
  6. }' \
  7. http://localhost:8000/queries.json \
  8. -w %{time_connect}:%{time_starttransfer}:%{time_total}
  1. curl -H "Content-Type: application/json" \
  2. -d '{
  3. "user" : "u1",
  4. "num": 10,
  5. "whiteList": ["i21", "i26", "i40"]
  6. }' \
  7. http://localhost:8000/queries.json \
  8. -w %{time_connect}:%{time_starttransfer}:%{time_total}
  1. curl -H "Content-Type: application/json" \
  2. -d '{
  3. "user" : "u1",
  4. "num": 10,
  5. "blackList": ["i21", "i26", "i40"]
  6. }' \
  7. http://localhost:8000/queries.json \
  8. -w %{time_connect}:%{time_starttransfer}:%{time_total}

unknown user:

  1. curl -H "Content-Type: application/json" \
  2. -d '{
  3. "user" : "unk1",
  4. "num": 10}' \
  5. http://localhost:8000/queries.json \
  6. -w %{time_connect}:%{time_starttransfer}:%{time_total}

handle new user

new user:

  1. curl -H "Content-Type: application/json" \
  2. -d '{
  3. "user" : "x1",
  4. "num": 10}' \
  5. http://localhost:8000/queries.json \
  6. -w %{time_connect}:%{time_starttransfer}:%{time_total}

import some view events and try to get recommendation for x1 again.

  1. accessKey=<YOUR_ACCESS_KEY>
  1. curl -i -X POST http://localhost:7070/events.json?accessKey=$accessKey \
  2. -H "Content-Type: application/json" \
  3. -d '{
  4. "event" : "view",
  5. "entityType" : "user"
  6. "entityId" : "x1",
  7. "targetEntityType" : "item",
  8. "targetEntityId" : "i2",
  9. "eventTime" : "2015-02-17T02:11:21.934Z"
  10. }'
  11. curl -i -X POST http://localhost:7070/events.json?accessKey=$accessKey \
  12. -H "Content-Type: application/json" \
  13. -d '{
  14. "event" : "view",
  15. "entityType" : "user"
  16. "entityId" : "x1",
  17. "targetEntityType" : "item",
  18. "targetEntityId" : "i3",
  19. "eventTime" : "2015-02-17T02:12:21.934Z"
  20. }'

handle unavailable items

Set the following items as unavailable (need to specify complete list each time when this list is changed):

  1. curl -i -X POST http://localhost:7070/events.json?accessKey=$accessKey \
  2. -H "Content-Type: application/json" \
  3. -d '{
  4. "event" : "$set",
  5. "entityType" : "constraint"
  6. "entityId" : "unavailableItems",
  7. "properties" : {
  8. "items": ["i43", "i20", "i37", "i3", "i4", "i5"],
  9. }
  10. "eventTime" : "2015-02-17T02:11:21.934Z"
  11. }'

Set empty list when no more items unavailable:

  1. curl -i -X POST http://localhost:7070/events.json?accessKey=$accessKey \
  2. -H "Content-Type: application/json" \
  3. -d '{
  4. "event" : "$set",
  5. "entityType" : "constraint"
  6. "entityId" : "unavailableItems",
  7. "properties" : {
  8. "items": [],
  9. }
  10. "eventTime" : "2015-02-18T02:11:21.934Z"
  11. }'