Personalized recommendations in Ruby

Pavel Kordík
Recombee blog
Published in
1 min readMay 15, 2016


For those of you, who develop in Ruby, we prepared a simple client application enabling you to benefit from our personalized recommendations.

Ruby is getting increasingly popular programming language.

Here is how you can integrate in into your website or application:

require 'recombee_api_client'
include RecombeeApiClient

# Prepare some items and users
NUM = 100
my_users = (1..NUM).map { |i| "user-#{i}" }
my_items = (1..NUM).map { |i| "item-#{i}" }

#Generate some random purchases of items by users
my_purchases = []
my_users.each do |user|
p = { |_| rand(0.0..1.0) < PROBABILITY_PURCHASED }
p.each { |item| my_purchases.push('userId' => user, 'itemId' => item) }

# Use Recombee recommender
client ='client-test', 'jGGQ6ZKa8rQ1zTAyxTc0EMn55YPF7FJLUtaMLhbsGxmvwxgTwXYqmUk5xVZFw98L')
# Send the data to Recombee, use Batch for faster processing
puts 'Send users'
client.send( { |userId| }))
puts 'Send items'
client.send( { |itemId| }))
puts 'Send purchases'
client.send( { |p|['userId'], p['itemId'], 0) }))
# Get recommendations for user 'user-25'
puts 'Recommend for a user'
recommended = client.send('user-25', 5, 'rotationRate' => 0))
puts "Recommended items: #{recommended}"
rescue ResponseError => e
puts e

Get access token by requesting free trial option at our website and evaluate quality of our service now.



Pavel Kordík
Recombee blog

@FIT_CTU, @DataLab_CTU, @recombee,