Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix a bug where predictions are always 0.0

Signed-off-by: David Celis <david@davidcelis.com>
  • Loading branch information...
commit c8efb83896160ed8a9cd64606920133fa9a58484 1 parent b7202f4
@davidcelis authored
View
9 lib/recommendable/helpers/calculations.rb
@@ -131,11 +131,12 @@ def predict_for(user_id, klass, item_id)
disliked_by_set = Recommendable::Helpers::RedisKeyMapper.disliked_by_set_for(klass, item_id)
similarity_sum = 0.0
- Recommendable.redis.smembers(liked_by_set).inject(similarity_sum) do |sum, id|
- sum += Recommendable.redis.zscore(similarity_set, id).to_f
+ similarity_sum += Recommendable.redis.smembers(liked_by_set).inject(0) do |memo, id|
+ memo += Recommendable.redis.zscore(similarity_set, id).to_f
end
- Recommendable.redis.smembers(disliked_by_set).inject(similarity_sum) do |sum, id|
- sum -= Recommendable.redis.zscore(similarity_set, id).to_f
+
+ similarity_sum += Recommendable.redis.smembers(disliked_by_set).inject(0) do |memo, id|
+ memo -= Recommendable.redis.zscore(similarity_set, id).to_f
end
liked_by_count = Recommendable.redis.scard(liked_by_set)
View
4 lib/recommendable/version.rb
@@ -1,8 +1,8 @@
module Recommendable
MAJOR = 2
MINOR = 0
- PATCH = 0
- PRE = 20121011
+ PATCH = 1
+ PRE = nil
VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join '.'
end

0 comments on commit c8efb83

Please sign in to comment.
Something went wrong with that request. Please try again.