disco 0.1.3 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33961b51cd8461f821c4622f5983b2ac6138cc3b70c9be8ef1d3a6e82c37ab9e
4
- data.tar.gz: f4e8cdfa4efb354878c459b57b522a81cd3f0c81e4297c53f9dc88517b312ac8
3
+ metadata.gz: 96836166496bb14ec8f973fb5e3709e0a28b7d5d8678608d074c0d7613076cc2
4
+ data.tar.gz: c68d12941fddc51a67938ef951be4ee809faef2e131de0f5856908d8ed1f93d9
5
5
  SHA512:
6
- metadata.gz: 2f4c207486e858a23480e52b4b9a479fd23b26f0259ef12e39b964d9d7f4cc0067f162207d88119f76414269d65e3ee3d7c675c46f5f143c5b016eacab6e888c
7
- data.tar.gz: 2734c1dcc87c423566dd2f842ef7fdd1b7e3cbaa1ecac61dbfafdbc1769b43edca81d28ce60712008eee9d381d64c9e2dea71b210c1a10fecaef75696ee2fd05
6
+ metadata.gz: 8b960dc961ead701713dbc7f9c104852355ac6d61f9f1f6e1cde43d1d4fa257b2c55859ca42896a6780f006d25f5ff613bf0261e601033db7d3c063f2a9f3d3e
7
+ data.tar.gz: 6c82413ce53a9100fc97f9a3849c6231ebee4945fd26a3e3a1150f8c3abcca915032d35f4373b83217fa786600181097c003d1d071aab9de00612baf4c4eaa99
@@ -1,3 +1,7 @@
1
+ ## 0.2.0 (2020-07-31)
2
+
3
+ - Changed score to always be between -1 and 1 for `item_recs` and `similar_users` (cosine similarity - this makes it easier to understand and consistent with `optimize_item_recs` and `optimize_similar_users`)
4
+
1
5
  ## 0.1.3 (2020-06-28)
2
6
 
3
7
  - Added support for Rover
@@ -1,4 +1,4 @@
1
- Copyright (c) 2019 Andrew Kane
1
+ Copyright (c) 2019-2020 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -101,14 +101,14 @@ recommender.item_recs("Star Wars (1977)")
101
101
  ```ruby
102
102
  views = Ahoy::Event.
103
103
  where(name: "Viewed post").
104
- group(:user_id, "properties->>'post_id'") # postgres syntax
104
+ group(:user_id, "properties->>'post_id'"). # postgres syntax
105
105
  count
106
106
 
107
107
  data =
108
108
  views.map do |(user_id, post_id), count|
109
109
  {
110
110
  user_id: user_id,
111
- post_id: post_id,
111
+ item_id: post_id,
112
112
  value: count
113
113
  }
114
114
  end
@@ -36,8 +36,7 @@ module Disco
36
36
 
37
37
  return dest if File.exist?(dest)
38
38
 
39
- temp_dir ||= File.dirname(Tempfile.new("disco"))
40
- temp_path = "#{temp_dir}/#{Time.now.to_f}" # TODO better name
39
+ temp_path = "#{Dir.tmpdir}/disco-#{Time.now.to_f}" # TODO better name
41
40
 
42
41
  digest = Digest::SHA2.new
43
42
 
@@ -139,7 +139,7 @@ module Disco
139
139
  end
140
140
 
141
141
  def norms(factors)
142
- norms = Numo::DFloat::Math.sqrt((factors * factors).sum(axis: 1))
142
+ norms = Numo::SFloat::Math.sqrt((factors * factors).sum(axis: 1))
143
143
  norms[norms.eq(0)] = 1e-10 # no zeros
144
144
  norms
145
145
  end
@@ -171,8 +171,7 @@ module Disco
171
171
  predictions = predictions.first(count) if count
172
172
  # divide by max score to get cosine similarity
173
173
  # only need to do for returned records
174
- # could alternatively do cosine distance = 1 - cosine similarity
175
- # predictions.each { |pred| pred[:score] /= max_score }
174
+ predictions.each { |pred| pred[:score] /= max_score }
176
175
  predictions
177
176
  end
178
177
  else
@@ -1,3 +1,3 @@
1
1
  module Disco
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: disco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-29 00:00:00.000000000 Z
11
+ date: 2020-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libmf
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: 0.2.3
145
+ version: 0.3.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
- version: 0.2.3
152
+ version: 0.3.0
153
153
  description:
154
154
  email: andrew@chartkick.com
155
155
  executables: []