ProductPromotion
Logo

Ruby

made by https://0x3d.site

GitHub - apache/predictionio-sdk-ruby: PredictionIO Ruby SDK
PredictionIO Ruby SDK. Contribute to apache/predictionio-sdk-ruby development by creating an account on GitHub.
Visit Site

GitHub - apache/predictionio-sdk-ruby: PredictionIO Ruby SDK

GitHub - apache/predictionio-sdk-ruby: PredictionIO Ruby SDK

Apache PredictionIO Ruby SDK

Build Status Gem Version

The Ruby SDK provides a convenient wrapper for PredictionIO Event Server API and Engine API. It allows you to quickly record your users' behavior and retrieve personalized predictions for them.

Documentation

Full Ruby SDK documentation can be found here.

Please see the PredictionIO App Integration Overview to understand how the SDK can be used to integrate PredictionIO Event Server and Engine with your application.

Installation

Ruby 2+ required!

The module is published to RubyGems and can be installed directly by:

gem install predictionio

Or using Bundler with:

gem 'predictionio', '0.12.1'

Sending Events to Event Server

Please refer to Event Server documentation for event format and how the data can be collected from your app.

Instantiate Event Client and connect to PredictionIO Event Server

require 'predictionio'

# 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'], Integer(ENV['PIO_THREADS']))

Create a $set user event and send it to Event Server

client.create_event(
  '$set',
  'user',
  user_id
)

Create a $set item event and send it to Event Server

client.create_event(
  '$set',
  'item',
  item_id,
  { 'properties' => { 'categories' => ['Category 1', 'Category 2'] } }
)

Create a $set item event and send it to Event Server to specific channel

NOTE: channels are supported in PIO version >= 0.9.2 only. Channel must be created first.

client.create_event(
  '$set',
  'item',
  item_id,
  { 'properties' => { 'categories' => ['Category 1', 'Category 2'], 'channel' => 'test-channel'} }
)

Create a user 'rate' item event and send it to Event Server

client.create_event(
  'rate',
  'user',
  user_id, {
    'targetEntityType' => 'item',
    'targetEntityId' => item_id,
    'properties' => { 'rating' => 10 }
  }
)

Asynchronous request

To send an async request, simply use the acreate_event method instead of create_event. Be aware that the asynchronous method does not throw errors. It's best to use the synchronous method when first getting started.

Query PredictionIO Engine

Connect to the Engine:

# Define environmental variables.
ENV['PIO_ENGINE_URL'] = 'http://localhost:8000'

# Create PredictionIO engine client.
client = PredictionIO::EngineClient.new(ENV['PIO_ENGINE_URL'])

Send a prediction query to the engine and get the predicted result:

# Get 5 recommendations for items similar to 10, 20, 30.
response = client.send_query(items: [10, 20, 30], num: 5)

Mailing List

Please use the Apache mailing lists. Subscription instructions are here.

Issue Tracker

Use the Apache JIRA, and file any issues under the Ruby SDK component.

Contributing

Please follow these instructions.

License

Apache License 2.0.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory