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
<?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
<?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 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 | |
// Use Composer's autoloader to load PredictionIO PHP SDK. | |
require_once("vendor/autoload.php"); | |
use PredictionIO\PredictionIOClient; | |
// 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 = PredictionIOClient::factory(array("appkey" => "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
{ | |
"require": { | |
"predictionio/predictionio": "~0.6.0" | |
} | |
} |
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
curl -sS https://getcomposer.org/installer | php -d detect_unicode=Off |
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 composer.phar install |
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: |
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. | |
# Suggest similar funded projects | |
try: | |
# retreive top 5 similar funded projects | |
result = client.get_itemsim_topn("itemsim-fund", "the project ID", 5) | |
iids = result['pio_iids'] # list of recommended project IDs | |
except Exception as e: | |
iids = get_default_iids_list(5) # default behavior when no prediction results. eg. recommends the latest funded projects | |
log_error(e) # Handle error here. You may log the error for debugging. | |