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
<?php | |
// Assuming we already have an ItemRec engine named 'similarapps' | |
// Get app ID | |
$app = getApp(); | |
try { | |
// Retrieve similar apps for the current app | |
$command = $client->getCommand( | |
'itemsim_get_top_n', |
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
<?php | |
// Assuming we already have an ItemRec engine named 'appsrec' | |
// Get user ID and the current view's category | |
$uid = getUid(); | |
$category = getCategory(); | |
try { | |
// Retrieve apps recommendation for the current user and category |
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
<?php | |
// Assuming we already have an ItemSim engine named 'similarapps' | |
// Get a list of previous viewed app IDs for the current session | |
$previouslyViewedApps = getViewedAppsInThisSession(); | |
$similarApps = array(); | |
try { | |
// Retrieve similar apps for each previously viewed app |
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 io.prediction.ItemSimGetTopNRequestBuilder; | |
// You need to specify the name of the engine from which you want to retrieve the prediction results. | |
// Add the following code to display similar sightseeing spots to the user after arriving a destination: | |
String[] destinationIds; | |
try { | |
//retreive top 5 similar sightseeing spots from the item similarity engine | |
String[] itypes = {"sightseeing"} |
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
// When a new destination is added: | |
try { | |
// sightseeing spot type may be "museums", "landmarks", etc | |
String[] itypes = {"destinations", "sightseeing", "sightseeing spot type 1", "sightseeing spot type 2"}; | |
client.createItem("destination ID or name", itypes); | |
} catch (Exception e) { | |
handleException(e); | |
} | |
// When the logged-in user goes to a destination: |
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 io.prediction.ItemRecGetTopNRequestBuilder; | |
// You need to specify the name of the engine from which you want to retrieve the prediction results. | |
// Add the following code to display recommended drivers to the logged-in user: | |
String[] driverIds; | |
try { | |
// Retrieve top 5 recommended drivers from the item recommendation engine. | |
// Assuming client.identify("user id") is already called when the user logged in. |
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 io.prediction.Client; | |
import io.prediction.UserActionItemRequestBuilder; | |
import io.prediction.CreateItemRequestBuilder; | |
// 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: | |
Client client = new Client("your app key"); | |
// Then add the following lines to your codes which handle the corresponding application logic: |
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
<ivy-module ...> | |
... | |
<dependencies> | |
<dependency org="io.prediction" name="client" rev="0.6.0" /> | |
... | |
</dependencies> | |
... | |
</ivy-module> |
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
<project ...> | |
... | |
<dependencies> | |
<dependency> | |
<groupId>io.prediction</groupId> | |
<artifactId>client</artifactId> | |
<version>0.6.0</version> | |
</dependency> | |
</dependencies> | |
... |
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 a user views a meal, you can suggest similar meals to the user by adding the following: | |
begin | |
# retreive top 5 similar courses from the item similarity engine | |
iids = client.get_itemsim_top_n("the engine name", "the viewed meal ID", 5) # list of recommended meal IDs | |
rescue ItemSimNotFoundError => e | |
iids = get_default_iids_list(5) # default behavior when there is no prediction results, e.g. recommends newest meals | |
log_error(e) # log the error for debugging or analysis later | |
end |