/cofi_cost

Playground for collaborative filtering in Ruby using NArray and rb-gsl.

Primary LanguageRuby

About

Playground for collaborative filtering in Ruby using NArray and rb-gsl.

Usage

Create a variable to store the ratings as an NArray (number of users x number of tracks).

Set the number of features to learn, lambda (regularization parameter), and the number of iterations of gradient descent.

Call min_cost

ratings = NArray[[5.0,4.0,0.0,0.0],[3.0,0.0,0.0,0.0],[4.0,0.0,0.0,0.0],[3.0,0.0,0.0,0.0],[3.0,0.0,0.0,0.0]]
num_features = 2
lambda = 1
iterations = 10
cofi = CofiCost.new(ratings, num_features, lambda, iterations, nil, nil)
cofi.min_cost

The cost and predictions (an NArray of the original size of ratings) can then be
returned after running min_cost:

cofi.cost
cofi.predictions

Installation

gem

rails 3.2

  1. gem ‘cofi_cost’
    in your Gemfile
  2. bundle install
    from the command line

Thank you
Professor Andrew Ng for his wonderful Machine Learning class: ml-class.org

License

MIT License 2012 Thomas Wolfe