commit | 6c75dbe67ae941cd44a8badf89dbfc5c2a8011c6 | [log] [tgz] |
---|---|---|
author | David Singer <david@ramaboo.com> | Mon Mar 30 13:09:48 2015 -0700 |
committer | David Singer <david@ramaboo.com> | Mon Mar 30 13:09:48 2015 -0700 |
tree | e648f3917333e725a7bc0deb14936d43c1e5f223 | |
parent | 287f7a5bcaf885258bbd28a3518e81ed8878ad64 [diff] | |
parent | b05b7cbd2cc818f9ac2b50b27806145382bedbbd [diff] |
Merge branch 'develop' of github.com:PredictionIO/PredictionIO-Ruby-SDK into develop
The Ruby SDK provides a convenient wrapper for the PredictionIO API. It allows you to quickly record your users' behavior and retrieve personalized predictions for them.
Ruby 1.9.3+ required!
The module is published to RubyGems and can be installed directly by:
gem install predictionio
Or using Bundler with:
gem 'predictionio', '0.9.0'
Connect to the Event Server with:
# Define environment variables. ENV['PIO_THREADS'] = 50 # For async requests. ENV['PIO_EVENT_SERVER_URL'] = 'http://localhost:7070' ENV['PIO_ACCESS_KEY'] = 'YOUR_ACCESS_KEY' # Find your access key with: `$ pio app list`. # Create PredictionIO event client. client = PredictionIO::EventClient.new(ENV['PIO_ACCESS_KEY'], ENV['PIO_EVENT_SERVER_URL'], ENV['PIO_THREADS'])
user_id = User.find(...).id client.create_event( '$set', 'user', user_id )
item_id = Model.find(...).id client.create_event( '$set', 'item', item_id, { 'properties' => { 'categories' => ['Category 1', 'Category 2'] } } )
client.create_event( 'rate', 'user', user_id, { 'targetEntityType' => 'item', 'targetEntityId' => item_id, 'properties' => { 'rating' => 10 } } )
To use an async request simply change create_event
to acreate_event
. The asynchronous method wont though an error though so it's best to start with the synchronous one.
Connect to the PredictionIO Engine with:
# Define environmental variables. ENV['PIO_ENGINE_URL'] = 'http://localhost:8000' # Create PredictionIO engine client. client = PredictionIO::EngineClient.new(ENV['PIO_ENGINE_URL'])
# Get 5 recommendations for items similar to 10, 20, 30. response = client.send_query(items: [10, 20, 30], num: 5)
RDoc is available online.
View Google Group
Use JIRA or GitHub Issues.
We follow the [git-flow] (http://nvie.com/posts/a-successful-git-branching-model/) model where all active development goes to the develop branch, and releases go to the master branch. Pull requests should be made against the develop branch and include relevant tests, if applicable. Please sign our Contributor Agreement before submitting a pull request.