Module: CollaborativeFiltering::Sample
- Defined in:
- lib/collaborative_filtering/sample.rb
Constant Summary collapse
- SAMPLE =
{ 'Yamada' => { 'Curry' => 2.5, 'Ramen' => 3.5, 'Fried rice' => 3.0, 'Sushi' => 3.5, 'Beef bowl' => 2.5, 'Wheat noodle' => 3.0 }, 'Tanaka' => { 'Curry' => 3.0, 'Ramen' => 3.5, 'Fried rice' => 1.5, 'Sushi' => 5.0, 'Wheat noodle' => 3.0, 'Beef bowl' => 3.5 }, 'Sato' => { 'Curry' => 2.5, 'Ramen' => 3.0, 'Sushi' => 3.5, 'Wheat noodle' => 4.0 }, 'Nakamura' => { 'Ramen' => 3.5, 'Fried rice' => 3.0, 'Wheat noodle' => 4.5, 'Sushi' => 4.0, 'Beef bowl' => 2.5 }, 'Kawamura' => { 'Curry' => 3.0, 'Ramen' => 4.0, 'Fried rice' => 2.0, 'Sushi' => 3.0, 'Wheat noodle' => 3.0, 'Beef bowl' => 2.0 }, 'Suzuki' => { 'Curry' => 3.0, 'Ramen' => 4.0, 'Wheat noodle' => 3.0, 'Sushi' => 5.0, 'Beef bowl' => 3.5 }, 'Shimobayashi' => { 'Ramen' => 4.5, 'Beef bowl' => 1.0, 'Sushi' => 4.0 } }
Class Method Summary collapse
- .all_sample ⇒ Object
- .get_recommendations ⇒ Object
- .show_sample_data ⇒ Object
- .sim_distance ⇒ Object
- .sim_pearson ⇒ Object
- .top_matches ⇒ Object
- .transform_prefs ⇒ Object
Class Method Details
.all_sample ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/collaborative_filtering/sample.rb', line 59 def all_sample puts %( ////////////////////////////////////////////////////////////// // this source exists lib/collaborative_filtering/sample.rb // ////////////////////////////////////////////////////////////// ) show_sample_data sim_distance sim_pearson top_matches get_recommendations transform_prefs end |
.get_recommendations ⇒ Object
88 89 90 91 |
# File 'lib/collaborative_filtering/sample.rb', line 88 def get_recommendations puts "write like this -> CollaborativeFiltering.get_recommendations(SAMPLE, 'Shimobayashi')" p CollaborativeFiltering.get_recommendations(SAMPLE, 'Shimobayashi') end |
.show_sample_data ⇒ Object
55 56 57 |
# File 'lib/collaborative_filtering/sample.rb', line 55 def show_sample_data p SAMPLE end |
.sim_distance ⇒ Object
73 74 75 76 |
# File 'lib/collaborative_filtering/sample.rb', line 73 def sim_distance puts "write like this -> CollaborativeFiltering.sim_distance(SAMPLE, 'Yamada', 'Tanaka')" p CollaborativeFiltering.sim_distance(SAMPLE, 'Yamada', 'Tanaka') end |
.sim_pearson ⇒ Object
78 79 80 81 |
# File 'lib/collaborative_filtering/sample.rb', line 78 def sim_pearson puts "write like this -> CollaborativeFiltering.sim_pearson(SAMPLE, 'Yamada', 'Tanaka')" p CollaborativeFiltering.sim_pearson(SAMPLE, 'Yamada', 'Tanaka') end |
.top_matches ⇒ Object
83 84 85 86 |
# File 'lib/collaborative_filtering/sample.rb', line 83 def top_matches puts "write like this -> CollaborativeFiltering.top_matches(SAMPLE, 'Shimobayashi')" p CollaborativeFiltering.top_matches(SAMPLE, 'Shimobayashi') end |
.transform_prefs ⇒ Object
93 94 95 96 97 98 |
# File 'lib/collaborative_filtering/sample.rb', line 93 def transform_prefs puts "write like this -> menu = CollaborativeFiltering.transform_prefs(SAMPLE)" puts "write like this -> CollaborativeFiltering.top_matches(menu, 'Sushi')" = CollaborativeFiltering.transform_prefs(SAMPLE) p CollaborativeFiltering.top_matches(, 'Sushi') end |