Module: RecommEngine

Defined in:
lib/recommengine.rb,
lib/recommengine/flipper.rb,
lib/recommengine/matcher.rb,
lib/recommengine/test_data.rb,
lib/recommengine/calculator.rb,
lib/recommengine/recommender.rb,
lib/recommengine/pearson_calculator.rb,
lib/recommengine/euclidean_calculator.rb

Defined Under Namespace

Classes: Calculator, EuclideanCalculator, Flipper, Matcher, PearsonCalculator, Recommender

Constant Summary collapse

DEFAULT_ALGORITHM =
'Pearson'
DEFAULT_MATCHES_NUMBER =
3
WU_TANG =
{'Ghostface Killah'=> {'The Sixth Sense'=> 2.5, 'Snakes on a Plane'=> 3.5, '27 Dresses'=> 3.0, 'The Avengers'=> 3.5, 'Pootie Tang'=> 2.5, 'Titanic'=> 3.0},
'RZA'=> {'The Sixth Sense'=> 3.0, 'Snakes on a Plane'=> 3.5, '27 Dresses'=> 1.5, 'The Avengers'=> 5.0, 'Titanic'=> 3.0, 'Pootie Tang'=> 3.5},
'Raekwon'=> {'The Sixth Sense'=> 2.5, 'Snakes on a Plane'=> 3.0, 'The Avengers'=> 3.5, 'Titanic'=> 4.0},
'GZA'=> {'Snakes on a Plane'=> 3.5, '27 Dresses'=> 3.0, 'Titanic'=> 4.5, 'The Avengers'=> 4.0, 'Pootie Tang'=> 2.5},
'Method Man'=> {'The Sixth Sense'=> 3.0, 'Snakes on a Plane'=> 4.0, '27 Dresses'=> 2.0, 'The Avengers'=> 3.0, 'Titanic'=> 3.0,'Pootie Tang'=> 2.0},
'ODB' => {'The Sixth Sense'=> 3.0, 'Snakes on a Plane'=> 4.0, 'Titanic'=> 3.0, 'The Avengers'=> 5.0, 'Pootie Tang'=> 3.5},
'Inspectah Deck'=> {'Snakes on a Plane'=>4.5, 'Pootie Tang'=>1.0, 'The Avengers'=>4.0}}
CRITICS =
{"Lisa Rose"=>{"Lady in the Water"=>2.5, "Snakes on a Plane"=>3.5, "Just My Luck"=>3.0, "Superman Returns"=>3.5, "You, Me and Dupree"=>2.5, "The Night Listener"=>3.0},
"Gene Seymour"=>{"Lady in the Water"=>3.0, "Snakes on a Plane"=>3.5, "Just My Luck"=>1.5, "Superman Returns"=>5.0, "The Night Listener"=>3.0, "You, Me and Dupree"=>3.5},
"Michael Phillips"=>{"Lady in the Water"=>2.5, "Snakes on a Plane"=>3.0, "Superman Returns"=>3.5, "The Night Listener"=>4.0},
"Claudia Puig"=>{"Snakes on a Plane"=>3.5, "Just My Luck"=>3.0, "The Night Listener"=>4.5, "Superman Returns"=>4.0, "You, Me and Dupree"=>2.5},
"Mick LaSalle"=>{"Lady in the Water"=>3.0, "Snakes on a Plane"=>4.0, "Just My Luck"=>2.0, "Superman Returns"=>3.0, "The Night Listener"=>3.0, "You, Me and Dupree"=>2.0},
"Jack Matthews"=>{"Lady in the Water"=>3.0, "Snakes on a Plane"=>4.0, "The Night Listener"=>3.0, "Superman Returns"=>5.0, "You, Me and Dupree"=>3.5},
"Toby"=>{"Snakes on a Plane"=>4.5, "You, Me and Dupree"=>1.0,"Superman Returns"=>4.0}}
BOOKS =
{alice: {"War and Peace" => 2.5, "Crime and Punishment" => 3.5},
bob: {"War of the Worlds" => 5.0, "War and Peace" => 1.5, "The Great Gatsby" => 4.0},
cindy: {"War and Peace" => 5.0, "The Great Gatsby" => 4.5, "War of the Worlds" => 3.0, "Twenty Thousand Leagues Under the Sea" => 3.0},
don: {"War of the Worlds" => 4.0, "The Great Gatsby" => 2.5, "Twenty Thousand Leagues Under the Sea" => 5.0, "Crime and Punishment" => 4.5, "War and Peace" => 3.0},
erica: {"War of the Worlds" => 3.0, "The Great Gatsby" => 4.5, "Twenty Thousand Leagues Under the Sea" => 4.0, "Crime and Punishment" => 4.5, "War and Peace" => 3.5}}

Class Method Summary collapse

Class Method Details

.dissimilar_users(data:, subject:, similarity: RecommEngine::DEFAULT_ALGORITHM, num: RecommEngine::DEFAULT_MATCHES_NUMBER) ⇒ Object



23
24
25
# File 'lib/recommengine.rb', line 23

def dissimilar_users(data:, subject:, similarity: RecommEngine::DEFAULT_ALGORITHM, num: RecommEngine::DEFAULT_MATCHES_NUMBER)
  RecommEngine::Matcher.new(data: data, subject: subject, similarity: similarity, num: num).bottom_matches
end

.flip(data) ⇒ Object



27
28
29
# File 'lib/recommengine.rb', line 27

def flip(data)
  RecommEngine::Flipper.new(data).flip
end

.recs(data:, subject:, similarity: RecommEngine::DEFAULT_ALGORITHM) ⇒ Object



11
12
13
# File 'lib/recommengine.rb', line 11

def recs(data:, subject:, similarity: RecommEngine::DEFAULT_ALGORITHM)
  RecommEngine::Recommender.new(data: data, subject: subject, similarity: similarity).recs
end

.similar_users(data:, subject:, similarity: RecommEngine::DEFAULT_ALGORITHM, num: RecommEngine::DEFAULT_MATCHES_NUMBER) ⇒ Object



19
20
21
# File 'lib/recommengine.rb', line 19

def similar_users(data:, subject:, similarity: RecommEngine::DEFAULT_ALGORITHM, num: RecommEngine::DEFAULT_MATCHES_NUMBER)
  RecommEngine::Matcher.new(data: data, subject: subject, similarity: similarity, num: num).top_matches
end

.top_rec(data:, subject:, similarity: RecommEngine::DEFAULT_ALGORITHM) ⇒ Object



15
16
17
# File 'lib/recommengine.rb', line 15

def top_rec(data:, subject:, similarity: RecommEngine::DEFAULT_ALGORITHM)
  RecommEngine::Recommender.new(data: data, subject: subject, similarity: similarity).top_rec
end