This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pip install predictionio | |
Or | |
$ easy_install predictionio |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client.create_item("the new course ID", ("course category 1",)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import predictionio | |
# add this line to where initialization is done | |
client = predictionio.Client("your App Key") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client.create_user("the new user ID") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client.identify("the logged-in user ID") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client.record_action_on_item("view", "the viewed course ID") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client.record_action_on_item("conversion", "the enrolled course ID") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client.record_action_on_item("rate", "rated course ID", { "pio_rate": rating }) # the variable rating stores the rating value (from 1 to 5 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You need to specify the name of the engine from which you want to retrieve the prediction results. | |
# When any user views a course, you can suggest similar courses to the user by adding the following: | |
try: | |
# retreive top 5 similar courses from the item similarity engine | |
result = client.get_itemsim_topn("the engine name", "the viewed course ID", 5) | |
iids = result['pio_iids'] # list of recommended course IDs | |
except Exception as e: | |
iids = get_default_iids_list(5) # default behavior when no prediction results. eg. recommends latest courses | |
log_error(e) # log the error for debugging or analysis later | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You need to specify the name of the engine from which you want to retrieve the prediction results. | |
# Add the following code to display the recommended courses to the user after the user has logged in: | |
try: | |
# Retrieve top 5 recommnded courses from the item recommendation engine. | |
# Assuming client.identify("user id") is already called when the user logged in. | |
result = client.get_itemrec_topn("the engine name", 5) | |
iids = result['pio_iids'] # list of recommended course IDs | |
except Exception as e: | |
iids = get_default_iids_list(5) # default behavior when no prediction results. eg. recommends latest courses |
OlderNewer