collaborative_filtering 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +38 -0
- data/lib/collaborative_filtering/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b794ed0cd16798e0bd2668faaed2f8ab9586e3e
|
4
|
+
data.tar.gz: 3438b8c17792d3ca629f71f8be999a941b594d32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d96b693800974c9b2b93fe5ab6a6d18f2b0051c978204331b6f790ab577678f85560087477d732ae3352251b57541a894d6e30c2ce4b37d1431ab176424f42e8
|
7
|
+
data.tar.gz: 55ce7e3560cd05331ea92b0e83449049df5edcff8645130c759d060a101942e6fbff2199867b572a0f18b5d21190bf5a21815ccfa3d088ca243300a768cee738
|
data/README.md
CHANGED
@@ -25,6 +25,44 @@ Or install it yourself as:
|
|
25
25
|
|
26
26
|
## Usage
|
27
27
|
|
28
|
+
```ruby
|
29
|
+
require 'collaborative_filtering'
|
30
|
+
|
31
|
+
CollaborativeFiltering.all_sample
|
32
|
+
```
|
33
|
+
|
34
|
+
```
|
35
|
+
//////////////////////////////////////////////////////////////
|
36
|
+
// this source exists lib/collaborative_filtering/sample.rb //
|
37
|
+
//////////////////////////////////////////////////////////////
|
38
|
+
|
39
|
+
{
|
40
|
+
"Yamada"=>{"Curry"=>2.5, "Ramen"=>3.5, "Fried rice"=>3.0, "Sushi"=>3.5, "Beef bowl"=>2.5, "Wheat noodle"=>3.0},
|
41
|
+
"Tanaka"=>{"Curry"=>3.0, "Ramen"=>3.5, "Fried rice"=>1.5, "Sushi"=>5.0, "Wheat noodle"=>3.0, "Beef bowl"=>3.5},
|
42
|
+
"Sato"=>{"Curry"=>2.5, "Ramen"=>3.0, "Sushi"=>3.5, "Wheat noodle"=>4.0},
|
43
|
+
"Nakamura"=>{"Ramen"=>3.5, "Fried rice"=>3.0, "Wheat noodle"=>4.5, "Sushi"=>4.0, "Beef bowl"=>2.5},
|
44
|
+
"Kawamura"=>{"Curry"=>3.0, "Ramen"=>4.0, "Fried rice"=>2.0, "Sushi"=>3.0, "Wheat noodle"=>3.0, "Beef bowl"=>2.0},
|
45
|
+
"Suzuki"=>{"Curry"=>3.0, "Ramen"=>4.0, "Wheat noodle"=>3.0, "Sushi"=>5.0, "Beef bowl"=>3.5},
|
46
|
+
"Shimobayashi"=>{"Ramen"=>4.5, "Beef bowl"=>1.0, "Sushi"=>4.0}
|
47
|
+
}
|
48
|
+
|
49
|
+
write like this -> CollaborativeFiltering.sim_distance(SAMPLE, 'Yamada', 'Tanaka')
|
50
|
+
0.14814814814814814
|
51
|
+
|
52
|
+
write like this -> CollaborativeFiltering.sim_pearson(SAMPLE, 'Yamada', 'Tanaka')
|
53
|
+
0.39605901719066977
|
54
|
+
|
55
|
+
write like this -> CollaborativeFiltering.top_matches(SAMPLE, 'Shimobayashi')
|
56
|
+
[[0.9912407071619299, "Yamada"], [0.9244734516419049, "Kawamura"], [0.8934051474415647, "Nakamura"], [0.66284898035987, "Suzuki"], [0.38124642583151164, "Tanaka"]]
|
57
|
+
|
58
|
+
write like this -> CollaborativeFiltering.get_recommendations(SAMPLE, 'Shimobayashi')
|
59
|
+
[[3.3477895267131017, "Wheat noodle"], [2.8325499182641614, "Curry"], [2.530980703765565, "Fried rice"]]
|
60
|
+
|
61
|
+
write like this -> menu = CollaborativeFiltering.transform_prefs(SAMPLE)
|
62
|
+
write like this -> CollaborativeFiltering.top_matches(menu, 'Sushi')
|
63
|
+
[[0.6579516949597695, "Beef bowl"], [0.4879500364742689, "Curry"], [0.11180339887498941, "Ramen"], [-0.1798471947990544, "Wheat noodle"], [-0.42289003161103106, "Fried rice"]]
|
64
|
+
```
|
65
|
+
|
28
66
|
## Development
|
29
67
|
|
30
68
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|