Mahout Plugin for ruby on rails
Asked Answered
C

2

12

I want to use Apache Mahout in my project on Ruby on Rails for implementing recommendations and collaborative filtering. In Particular my requirements are:

  1. suggesting related tags.
  2. suggesting related articles.
  3. based on user's preferences prompt him for review of articles.
  4. based on geographical location, and other meta information of a user, suggest him similar users.

I am open to using any other solution (other than mahout) if it integrates with rails easily and fulfills my requirements.

Casework answered 18/1, 2010 at 5:51 Comment(1)
Collaborative filtering is not a particularly long algorithm to implement. You might spend substantially less time just implementing the algorithm than trying to get it to work with ruby on rails.Diphthongize
M
7

Mahout (and Hadoop) work pretty well within Rails running on JRuby. You can include Hadoop and Mahout jars like so:

require 'rubygems'
require 'java'

Dir["/mahout-base-dir/**/*.jar"].each { |jar| require jar }
Dir["/hadoop-base-dir/**/*.jar"].each { |jar| require jar }

Then you can include the Mahout classes you plan on using, for instance:

include_class 'org.apache.hadoop.fs.Path'
include_class 'org.apache.hadoop.conf.Configuration'
include_class 'org.apache.hadoop.fs.FileSystem'
include_class 'org.apache.mahout.clustering.spectral.common.AffinityMatrixInputJob'
include_class 'org.apache.mahout.clustering.spectral.kmeans.SpectralKMeansDriver'

From there, you can follow the Mahout Java Docs and JRuby conventions to build your Rails rec system.

That being said, I'm not sure that would be the best architecture for your site (hard to say without more detail). If your problem scale is large enough to warrant Mahout, it probably makes more sense to use Rails for just the web stuff, and generate your recommendations outside the web framework (for instance by generating affinities in nightly batches, etc.).

Monazite answered 3/10, 2011 at 23:54 Comment(0)
N
6

For what it's worth, the Mahout 'taste-web' module contains scripts that will build a ready-to-use web service around a Java-based Recommender, as a .war file that you can deploy on something like Tomcat, and then talk to via HTTP. That would be accessible from any platform that can make HTTP requests.

http://lucene.apache.org/mahout/taste.html#Standalone+server

Neuromuscular answered 22/1, 2010 at 4:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.