recommendable 2.1.0.1 → 2.1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/recommendable/helpers/calculations.rb +8 -0
- data/lib/recommendable/rater.rb +2 -2
- data/lib/recommendable/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c546b37739a601150d95da118ef2e6a329a61beb
|
4
|
+
data.tar.gz: ae11ffa0ee1362b3f117fdfece1039eaecb57f1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52e983ca6a66f6c5a141b4f651b3043d25e6a74e5c832e8bcf9638e5c774461f50d87b5ab2c1e44a0ddcfa0e817911d550f0d526aac3f9a16733a78a4ed63631
|
7
|
+
data.tar.gz: 10045b2b278f86be82fb47ba8237f7556a83d444dd08154f4239b256bcc35aaf63d8689552f8169b31461bf42b0966f6bcd568f9b32c85bf03f896f045e56481
|
@@ -12,6 +12,9 @@ module Recommendable
|
|
12
12
|
# @return [Float] the numeric similarity between this user and the passed user
|
13
13
|
# @note Similarity values are asymmetrical. `Calculations.similarity_between(user_id, other_user_id)` will not necessarily equal `Calculations.similarity_between(other_user_id, user_id)`
|
14
14
|
def similarity_between(user_id, other_user_id)
|
15
|
+
user_id = user_id.to_s
|
16
|
+
other_user_id = other_user_id.to_s
|
17
|
+
|
15
18
|
similarity = liked_count = disliked_count = 0
|
16
19
|
in_common = Recommendable.config.ratable_classes.each do |klass|
|
17
20
|
liked_set = Recommendable::Helpers::RedisKeyMapper.liked_set_for(klass, user_id)
|
@@ -82,6 +85,8 @@ module Recommendable
|
|
82
85
|
#
|
83
86
|
# @private
|
84
87
|
def update_recommendations_for(user_id)
|
88
|
+
user_id = user_id.to_s
|
89
|
+
|
85
90
|
nearest_neighbors = Recommendable.config.nearest_neighbors || Recommendable.config.user_class.count
|
86
91
|
Recommendable.config.ratable_classes.each do |klass|
|
87
92
|
rated_sets = [
|
@@ -138,6 +143,9 @@ module Recommendable
|
|
138
143
|
# @param [Fixnum, String] item_id the item's ID
|
139
144
|
# @return [Float] the probability that the user will like the item
|
140
145
|
def predict_for(user_id, klass, item_id)
|
146
|
+
user_id = user_id.to_s
|
147
|
+
item_id = item_id.to_s
|
148
|
+
|
141
149
|
similarity_set = Recommendable::Helpers::RedisKeyMapper.similarity_set_for(user_id)
|
142
150
|
liked_by_set = Recommendable::Helpers::RedisKeyMapper.liked_by_set_for(klass, item_id)
|
143
151
|
disliked_by_set = Recommendable::Helpers::RedisKeyMapper.disliked_by_set_for(klass, item_id)
|
data/lib/recommendable/rater.rb
CHANGED
@@ -77,13 +77,13 @@ module Recommendable
|
|
77
77
|
end
|
78
78
|
elsif method.to_s =~ /\A((?:dis)?liked|hidden|bookmarked)_(.+)_ids\z/
|
79
79
|
begin
|
80
|
-
send("#{$1}_ids_for", $2.classify.constantize)
|
80
|
+
send("#{$1}_ids_for", $2.classify.constantize, *args)
|
81
81
|
rescue NameError
|
82
82
|
super
|
83
83
|
end
|
84
84
|
elsif method.to_s =~ /\A((?:dis)?liked|hidden|bookmarked|recommended)_(.+)\z/
|
85
85
|
begin
|
86
|
-
send("#{$1}_for", $2.classify.constantize)
|
86
|
+
send("#{$1}_for", $2.classify.constantize, *args)
|
87
87
|
rescue NameError
|
88
88
|
super
|
89
89
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recommendable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.0.
|
4
|
+
version: 2.1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Celis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|