A web app to use the cold-start-recommender
This is a basic tornado application which provide a web interface to the cold-start-recommender
- tornado
- cold-start-recommender version >= 4.0.0
pip install cold-start-recommender-webapp
or from the source folder (same folder of the setup.py file):
pip install .
To Uninstall the package:
pip uninstall cold-start-recommender-webapp
csrec_webapp.py --port=8888
Items must have at least the following fields:
- A unique identifier. No matter if it is a string or an int, but must be unique.
- A type identifier. The recommender must be able to recognise which type of item is dealing with (program, series, news etc).
- Informative fields. Prior to use, the recommender must know which fields are the informative ones
The application must tell which action is performed by which user on which item.
For each user, the recommender can recommend different types of items.
Note that:
- The recommender does not consider which programs/series are scheduled for a certain day.
- Items for a certain period must be filtered by the user after the query.
- The recommender can filter the type of items (eg if programs or series or news should be recommended to a certain user), but cannot recommend the informative fields (eg "this user likes running shoes").
- Whenever not enough information is available, the recommender recommends the most popular items.
Insert or modify items.
POST
- unique_id: the name of the field used as unique id for the item
A list of items with type and category informations e.g.:
[{ "_id" : "item1", "type": "lady", "category" : "high_heels"},
{ "_id" : "item2", "type": "male", "category" : "mocassino"},
{ "_id" : "item3", "type": "unisex", "category" : "mocassino"},
{ "_id" : "item4", "type": "male", "category" : "mocassino"}]
Code: 200
Content: {}
Code: 404
Content: {}
curl -X POST -H "Content-Type: application/json" -d '[{ "_id" : "item1", "type": "lady", "category" : "high_heels"}, { "_id" : "item2", "type": "male", "category" : "mocassino"}, { "_id" : "item3", "type": "unisex", "category" : "mocassino"}, { "_id" : "item4", "type": "male", "category" : "mocassino"}]' 'http://localhost:8888/insertitems?unique_id=_id'
delete an item
DELETE
- item: item id of the item to delete
Code: 200
Content: {}
Code: 404
Content: {}
curl -X DELETE -H "Content-Type: application/json" 'http://localhost:8888/item?item=1'
POST
- item: the item id (program, series etc)
- user: This could be the value of rating, or could correspond to different actions (e.g. hated: -1, loved: +1)
- code: the rating
- only_info: true or false, default is false
Update/insert an action identified by code performed by {uid} on {item_id}. If users or item are not found they are created in the database.
Code: 200
Content: {}
Code: 404
Content: {}
curl -X POST -H "Content-Type: application/json" -d '{ "item_info" : ["type", "category"]}' 'http://localhost:8888/itemaction?item=item1&user=User1&code=1&only_info=false'
DELETE
- item_id: the item id (program, series etc)
- user_id: the user id
Delete a user action given a user_id and an item_id
Code: 200
Content: {}
Code: 404
Content: {}
curl -X DELETE -H "Content-Type: application/json" 'http://localhost:8888/itemaction?item_id=1&user_id=1'
POST
Stores information about action performed by {uid} on {other_uid}, like "follow", "like" etc. If id's are not found they are created in the database.
- user: email or session_id of the user. NB Always use email if available.
- code: This could be the liking factor, or could correspond to different actions (e.g. downvote: -1, follow: +1)
- user_to: the other user's id
Code: 200
Content: {}
Code: 404
Content: {}
curl -X POST 'http://elegans.it:8888/socialaction?user=User1&user_to=User2&code=3'
GET
Provide a list of recommended item_ids.
- user: email or session_id of the user. NB Always use email if available.
- fast: if set to any value, uses faster and less accurate algorithm
- limit: integer, number of items to return, default is 10
- type: type of items to be returned. NB: if a non-existent key is provided the recommender will return an empty list
Code: 200
Content: a list of items e.g.: {"items": ["item4", "item1", "item3", "item2", "User2"]}
Code: 404
Content: {}
curl -X GET 'http://localhost:8888/recommend?user=User1&limit=10'
DELETE
Remove all the actions of a user from the data structures
- user_id: user id
Code: 200
Content: {}
Code: 404
Content: {}
curl -X DELETE 'http://localhost:8000/user?user_id=User1'
POST
Whenever a user logs in not in the first session, the app should tell which session_id s/he was using during the previous sessions. All action associated to user_old will be associated to user_new.
- user_old: old user id
- user_new: new user id
Code: 200
Content: {}
Code: 404
Content: {}
curl -X POST 'http://localhost:8888/reconcile?user_old=User1&user_new=User2'
GET
Return a dictionary with two lists:
- itemaction: actions performed on items
- socialaction: actions performed on other users
- user: email or session_id of the user. NB Always use email if available..
Code: 200
Content: {}
Code: 404
Content: {}
curl -X GET 'http://localhost:8888/info/user?user=User1'
GET
List of user who performed any action on the item, and which action
- item: id of the item
Code: 200
Content: {}
Code: 404
Content: {}
curl -X GET 'http://localhost:8888/info/item?item=item1'
GET
serialize data on file
- filename: the path where to serialize the data, default is /tmp/dump.bin
Code: 200
Content: {}
Code: 404
Content: {}
curl -X GET 'http://localhost:8888/serialize?filename=/tmp/dump.bin'
GET
restore data from file
- filename: the path of the file which contains the serialized data
Code: 200
Content: {}
Code: 404
Content: {}
curl -X GET 'http://localhost:8888/restore?filename=/tmp/dump.bin'