github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

maccman / acts_as_recommendable

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 249
    • 5
  • Source
  • Commits
  • Network (5)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Collaborative Filtering for Rails — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Switch downcase to underscore. This prevents class names like FooBar 
mischa (author)
Fri Apr 17 03:53:15 -0700 2009
commit  234589ea2a09a505c9f5b8e6a98f0fa35805c1f7
tree    cfb80eccf09bcff397c9938fb1d841982f5e848e
parent  2fea9d46109fa46d8bf082e2f67474cdd9ed2326
acts_as_recommendable /
name age
history
message
file MIT-LICENSE Tue Jul 29 02:31:18 -0700 2008 First commit [maccman]
file README Thu Sep 11 07:46:36 -0700 2008 Add Book#similar_books [maccman]
file Rakefile Tue Jul 29 02:31:18 -0700 2008 First commit [maccman]
file init.rb Wed Feb 11 13:56:45 -0800 2009 fixed some Rails 2.1+ assumptions since I'm stu... [apsoto]
directory lib/ Fri Apr 17 03:53:15 -0700 2009 Switch downcase to underscore. This prevents cl... [mischa]
directory tasks/ Thu Oct 09 02:35:48 -0700 2008 Should say Gen dataset rather than Gen matrix [maccman]
directory test/ Thu Oct 09 02:35:08 -0700 2008 Add .gitignore for logs and test db [maccman]
README
ActsAsRecommendable
===================

ActsAsRecommendable is a plugin for Rails that simplifies collaborative filtering

The plugin provides a mechanism for finding loose associations between users and items which we can tell you
* Given a user, return other similar users based on what items they have all bought/bookmarked/rated/etc
* Given a user, return recommended items based on the items bought/bookmarked/rated/etc by that user and the items 
bought/bookmarked/rated/etc by other users.

The plugin calculations can be made online and offline and stored using the rails cache (such as memcache) for online 
retrieval. Online retrieval of recommendations uses item-based collaborative filtering using the offline items 
similarity matrix stored in the cache. This can give up-to-date results with a much lower processing overhead.

Much thanks to Toby Segaran and his excellent book Programming Collective Intelligence 
(http://oreilly.com/catalog/9780596529321/).

Features
========

Use join rating scores
Using abitary calculated scores
Similar Items
Recommended Users
Cached dataset

Current Release
===============

v0.1 should be considered early alpha and not ready for production applications.

Lots of performance optimisations still to be done.

Example
=======

class Book < ActiveRecord::Base
  has_many :user_books
  has_many :users, :through => :user_books
end

class UserBook < ActiveRecord::Base
  belongs_to :book
  belongs_to :user
end

class User < ActiveRecord::Base
  has_many :user_books
  has_many :books, :through => :user_books
  acts_as_recommendable :books, :through => :user_books
end

user = User.find(:first)
user.similar_users #=> [...]
user.recommended_books #=> [...]

book = Book.find(:first)
book.similar_books #=> [...]

Example 2
=========

class Movie < ActiveRecord::Base
  has_many :user_movies
  has_many :users, :through => :user_movies
end

class UserMovie < ActiveRecord::Base
  belongs_to :movie
  belongs_to :user
end

class User < ActiveRecord::Base
  has_many :user_movies
  has_many :movies, :through => :user_movies
  acts_as_recommendable :movies, :through => :user_movies, :score => :score
  # 'score' is an attribute on the users_movies table
end

user = User.find(:first)
user.similar_users #=> [...]
user.recommended_movies #=> [...]

Example 3
=========

class Book < ActiveRecord::Base
  has_many :user_books
  has_many :users, :through => :user_books, :use_dataset => true
  # Uses cached dataset
end

class UserBook < ActiveRecord::Base
  belongs_to :book
  belongs_to :user
end

class User < ActiveRecord::Base
  has_many :user_books
  has_many :books, :through => :user_books
  acts_as_recommendable :books, :through => :user_books
end

user = User.find(:first)
user.recommended_books #=> [...]

# The example above uses a cached dataset.
# You need to generate a cached dataset every so often (depending on how much your content changes)
# You can do that by calling the rake task recommendations:build, you should run this with a cron job every so often.

  
# If you only want to use the dataset in production put this in production.rb:
  User.aar_options[:use_dataset] = true
  
# Note:
# user.similar_users doesn't use the dataset
#
# The advantage of using a dataset is that you don't need to load all the users & items into
# memory (which you do normally). The disadvantage is that you won't get as accurate results.
#

Contact
=======
alex@madebymany.co.uk


Copyright (c) 2008 Made by Many Ltd, released under the MIT license
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server