pearson 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/Gemfile +1 -3
  2. data/lib/pearson.rb +12 -12
  3. metadata +13 -10
  4. checksums.yaml +0 -7
  5. data/.ruby-version +0 -1
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- group :development do
4
- gem 'rspec', '>= 2.14.1'
5
- end
3
+ gem 'rspec', '>= 2.14.1'
data/lib/pearson.rb CHANGED
@@ -54,31 +54,31 @@ module Pearson
54
54
  # @param [Hash] Options (limit)
55
55
  #
56
56
  # @return [Array] Top matches [item, score]
57
- def recommendations(scores, person, opts={})
57
+ def recommendations(scores, entity, opts={})
58
58
  totals = {}
59
- similaritySums = {}
59
+ similarity_sums = {}
60
60
 
61
61
  totals.default = 0
62
- similaritySums.default = 0
62
+ similarity_sums.default = 0
63
63
 
64
- fail PersonNotFound unless scores[person]
64
+ fail EntityNotFound unless scores[entity]
65
65
 
66
- scores.each do |other_person|
67
- next if other_person.first == person
66
+ scores.each do |other_entity|
67
+ next if other_entity.first == entity
68
68
 
69
- similarity = coefficient(scores, person, other_person.first)
69
+ similarity = coefficient(scores, entity, other_entity.first)
70
70
 
71
71
  next if similarity <= 0
72
72
 
73
- scores[other_person.first].each do |item, score|
74
- if !scores[person].keys.include?(item) || scores[person][item] == 0
73
+ scores[other_entity.first].each do |item, score|
74
+ if !scores[entity].keys.include?(item) || scores[entity][item] == 0
75
75
  totals[item] += score * similarity
76
- similaritySums[item] += similarity
76
+ similarity_sums[item] += similarity
77
77
  end
78
78
  end
79
79
  end
80
80
 
81
- sort_desc(totals, opts) {|h, k, v| h.merge(k => v/similaritySums[k]) }
81
+ sort_desc(totals, opts) {|h, k, v| h.merge(k => v/similarity_sums[k]) }
82
82
  end
83
83
 
84
84
  private
@@ -103,6 +103,6 @@ module Pearson
103
103
  end
104
104
  end
105
105
 
106
- class PersonNotFound < StandardError; end
106
+ class EntityNotFound < StandardError; end
107
107
  end
108
108
 
metadata CHANGED
@@ -1,27 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pearson
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Alfonso Jiménez
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-01-04 00:00:00.000000000 Z
12
+ date: 2014-03-10 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rspec
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: 2.14.0
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - '>='
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: 2.14.0
27
30
  description: Pearson correlation coefficient calculator
@@ -33,29 +36,29 @@ extra_rdoc_files: []
33
36
  files:
34
37
  - Gemfile
35
38
  - LICENSE.txt
36
- - .ruby-version
37
39
  - lib/pearson.rb
38
40
  homepage: https://github.com/alfonsojimenez/pearson
39
41
  licenses: []
40
- metadata: {}
41
42
  post_install_message:
42
43
  rdoc_options: []
43
44
  require_paths:
44
45
  - lib
45
46
  required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
46
48
  requirements:
47
- - - '>='
49
+ - - ! '>='
48
50
  - !ruby/object:Gem::Version
49
51
  version: '0'
50
52
  required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
51
54
  requirements:
52
- - - '>='
55
+ - - ! '>='
53
56
  - !ruby/object:Gem::Version
54
57
  version: '0'
55
58
  requirements: []
56
59
  rubyforge_project:
57
- rubygems_version: 2.0.3
60
+ rubygems_version: 1.8.23
58
61
  signing_key:
59
- specification_version: 4
62
+ specification_version: 3
60
63
  summary: Pearson correlation coefficient calculator
61
64
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: e0bbce86ff859e971101cf43995637d7d56d07f6
4
- data.tar.gz: 72e1811067f3d044213e55d1336d74a2c1163606
5
- SHA512:
6
- metadata.gz: b4f9b2327f220781a24f3ab96f0087c1a7819b33a6fa866137d05773e932b83448bda278a8c9e202894f6a72c842386864a7ab10e62661bcf1b1eaf62643b7ed
7
- data.tar.gz: d75ebd9be509a4aba48b2eb9d77574dc37aa46545c49cead8414f1b34cc187428a44d8068c525ad683f5e12b3604cfa5ee14df759dd08afce410165cc1419184
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.0.0-p247