Last active
December 26, 2015 04:19
-
-
Save predictioniogists/7092086 to your computer and use it in GitHub Desktop.
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 | |
# In the beginning of your application, you need to instantiate the PredictionIO client object. | |
# You need this client object to import data into PredictionIO and retrieve prediction results. | |
# Add this line to the place where you do initialization: | |
cient = predictionio.Client("your App Key") | |
# Then add the following lines to your codes which handle the corresponding application logic: | |
# When a new user registers: | |
try: | |
client.create_user("the new user ID") | |
except Exception as e: | |
log_error(e) # handle error here. You may log the error for debugging or retry importing | |
# When a new project is added: | |
try: | |
client.create_item("the new project ID", ("project category 1",)) # may add more than one category | |
except Exception as e: | |
log_error(e) # handle error here. You may log the error for debugging or retry importing | |
# When a user logs in: | |
try: | |
client.identify("the logged-in user ID") | |
except Exception as e: | |
log_error(e) # handle error here. You may log the error for debugging or retry importing | |
# When the logged-in user clicks or views a project: | |
try: | |
client.record_action_on_item("view", "the viewed project ID") | |
except Exception as e: | |
log_error(e) # handle error here. You may log the error for debugging or retry importing | |
# When the logged-in user funds a project: | |
# use built-in action "conversion" to represent the "fund" action | |
try: | |
client.record_action_on_item("conversion", "the funded project ID") | |
except Exception as e: | |
log_error(e) # handle error here. You may log the error for debugging or retry importing | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Typo on line 6: 'cient' should be 'client'.
https://gist.github.com/mpritham/3a51f996bb74fe9c3d3b/2a24f0e16d013e5a30ef487f216006a826cfddf6