Last active
December 23, 2015 23:09
-
-
Save predictioniogists/6707826 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 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. | |
ItemRecGetTopNRequestBuilder builder = client.getItemRecGetTopNRequestBuilder("the engine name", 5) | |
.latitude(latitude) // current latitude of the user. eg. latitude = 37.7881 | |
.longitude(longitude); // current longitude of the user. eg. longitude = 122.4075 | |
driverIds = client.getItemRecTopN(builder); | |
} catch (Exception e) { // exception is raised when there is no prediction result. | |
driverIds = getDefaultDrivers(5); // default behavior when there is no recommendation. eg. get nearest 5 drivers | |
handleException(e); | |
} | |
displayDrivers(driverIds); // display drivers to the user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment