Monday, May 7, 2012

ruby-recommender gem

I have just started developing a Ruby Gem for a recommendation engine based on concepts from  Apache Mahout.

The gem is located in here github. At the moment it is very basic. An example of usage follows:

require 'recommendations'

    def save_as_csv_file(file_path,values),'w') do |file|
         values.each do |row|
           file.puts "#{row[0]},#{row[1]},#{row[2]}"
    save_as_csv_file '/tmp/data_file',[['A','B',5],['A','C',3],['B','B',5],['B','C',3],['B','D',2]]
    data_model ='/tmp/data_file')
    similarity =
    neighborhood =,similarity,5,0.5)
    rating_estimator =,similarity)
    recommender =,similarity,neighborhood,rating_estimator)
    recommendations = recommender.recommend('A',5)
    puts recommendations[0].item
    puts recommendations[0].value

I will be trying to expand it to do more things. The first of them will be adding MongoDB support as this is what I need for my project.

No comments: