Ruby in the world of recommendations (also machine learning, statistics and visualizations..) Marcel Caraciolo @marcelcaraciolo Developer, Cientist, contributor to the Crab recsys project, works with Python for 6 years, interested at mobile, education, machine learning and dataaaaa! Recife, Brazil - http://aimotion.blogspot.com Saturday, September 14, 2013
60
Embed
Recommender Systems with Ruby (adding machine learning, statistics, etc)
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Ruby in the world of recommendations
(also machine learning, statistics and visualizations..)
Marcel Caraciolo@marcelcaracioloDeveloper, Cientist, contributor to the Crab recsys project,works with Python for 6 years, interested at mobile,education, machine learning and dataaaaa!Recife, Brazil - http://aimotion.blogspot.com
Python was highly addopted and promoted by most of the research and
development team of Google
Saturday, September 14, 2013
Where is Ruby?Python lançado em 1991; Ruby lançado em 1995
Python foi altamente popularizado com a adoção oficial de boa parte do time de pesquisa do Google
Python has been an important key of Google since its beginning, and still continues as our infra-structure grows, we are always looking for more people with skills in this language.
Peter Norvig, Google, Inc.Saturday, September 14, 2013
Where is Ruby?
Python was famous even at some old scientific articles
#!/usr/bin/env ruby require 'bio' # create a DNA sequence object from a Stringdna = Bio::Sequence::NA.new("atcggtcggctta") # create a RNA sequence object from a Stringrna = Bio::Sequence::NA.new("auugccuacauaggc") # create a Protein sequence from a Stringaa = Bio::Sequence::AA.new("AGFAVENDSA") # you can check if the sequence contains illegal characters# that is not an accepted IUB character for that symbol# (should prepare a Bio::Sequence::AA#illegal_symbols method also)puts dna.illegal_bases # translate and concatenate a DNA sequence to Protein sequencenewseq = aa + dna.translateputs newseq # => "AGFAVENDSAIGRL"
Recommendable.configure do |config| # Recommendable's connection to Redis config.redis = Redis.new(:host => 'localhost', :port => 6379, :db => 0)
# A prefix for all keys Recommendable uses config.redis_namespace = :recommendable
# Whether or not to automatically enqueue users to have their recommendations # refreshed after they like/dislike an item config.auto_enqueue = true
# The name of the queue that background jobs will be placed in config.queue_name = :recommendable
# The number of nearest neighbors (k-NN) to check when updating # recommendations for a user. Set to `nil` if you want to check all # other users as opposed to a subset of the nearest ones. config.nearest_neighbors = nilend
Create a configuration initializer:
Saturday, September 14, 2013
RecommendableIn your ONE model that will be receiving the
recommendations:
class User recommends :movies, :books, :minerals, :other_things
# ...end
Saturday, September 14, 2013
Recommendable
>> current_user.liked_movies.limit(10)>> current_user.bookmarked_books.where(:author => "Cormac McCarthy")>> current_user.disliked_movies.joins(:cast_members).where('cast_members.name = Kim Kardashian')
Marcel likes A, B, C and dislikes DAmanda likes A, B and dislikes CGuilherme likes C, D and dislikes AFlavio likes B, C, E and dislikes D
Saturday, September 14, 2013
RecommendableRecommendations
>> Movie.top=> #<Movie name: "2001: A Space Odyssey">>> Movie.top(3)=> [#<Movie name: "2001: A Space Odyssey">, #<Movie name: "A Clockwork Orange">, #<Movie name: "The Shining">]
module Recommendable module Workers class Resque include ::Resque::Plugins::UniqueJob if defined?(::Resque::Plugins::UniqueJob) @queue = :recommendable
def self.perform(user_id) Recommendable::Helpers::Calculations.update_similarities_for(user_id) Recommendable::Helpers::Calculations.update_recommendations_for(user_id) end end endend
Recommendations over Queueing SystemPut the workers to do the job! (SideKiq, Resque, DelayedJob)
Saturday, September 14, 2013
Recommended Books
SatnamAlag, Collective Intelligence in Action, Manning Publications, 2009
(also machine learning, statistics and visualizations..)
Marcel Caraciolo@marcelcaracioloDeveloper, Cientist, contributor to the Crab recsys project,works with Python for 6 years, interested at mobile,education, machine learning and dataaaaa!Recife, Brazil - http://aimotion.blogspot.com