Skip to content

Instantly share code, notes, and snippets.

View predictioniogists's full-sized avatar

PredictionIO predictioniogists

View GitHub Profile
@predictioniogists
predictioniogists / event.swift
Created March 18, 2015 04:51
Event collection in Swift
let eventClient = EventClient(accessKey: accessKey, baseURL: "http://localhost:7070")
let event = Event(
event: "view",
entityType: "user",
entityID: "16398de4-cd17-11e4-afdc-1681e6b88ec1",
targetEntityType: "item",
targetEntityID: "2274f58a-cd17-11e4-afdc-1681e6b88ec1"
)
eventClient.createEvent(event) { (request, response, JSON, error) in
@predictioniogists
predictioniogists / init.json
Last active August 29, 2015 13:56
Settings Initialization with Popular Rank Algorithm
{
"systeminfos": {
"version": {
"value": "0.6.8",
"description": "PredictionIO version"
},
"jars.pdioItemrecAlgo": {
"value": "predictionio-process-hadoop-scalding-assembly-0.6.8.jar"
},
"jars.pdioItemsimAlgo": {
# You need to specify the name of the engine from which you want to retrieve the prediction results.
# Add the following code to provide personalized recommendation to the user after the user has logged in:
try:
# Retrieve top 10 recommnded projects from the item recommendation engine.
# Assuming client.identify("user id") is already called when the user logged in.
result = client.get_itemrec_topn("itemrec engine name", 10)
iids = result['pio_iids'] # list of recommended project IDs
except Exception as e:
iids = get_default_iids_list(10) # default behavior when no prediction results. eg. recommends the latest created projects
# You need to specify the name of the engine from which you want to retrieve the prediction results.
# Suggest similar viewed projects
try:
# retreive top 5 similar viewed projects
result = client.get_itemsim_topn("itemsim-view", "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 viewed projects
log_error(e) # Handle error here. You may log the error for debugging.
# 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.
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:
php composer.phar install
curl -sS https://getcomposer.org/installer | php -d detect_unicode=Off
{
"require": {
"predictionio/predictionio": "~0.6.0"
}
}
<?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"));