cmfrec 0.3.3 → 0.4.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 +4 -4
- data/CHANGELOG.md +8 -0
- data/LICENSE.txt +1 -1
- data/lib/cmfrec/data.rb +14 -30
- data/lib/cmfrec/recommender.rb +29 -29
- data/lib/cmfrec/version.rb +1 -1
- data/lib/cmfrec.rb +5 -1
- data/vendor/aarch64-linux/COPYRIGHTS +57 -0
- data/vendor/aarch64-linux/LICENSE +23 -0
- data/vendor/aarch64-linux/libcmfrec.so +0 -0
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 69ad906f81dd246a338be341b9e80ed3737fcda945be654128116e16bef07626
|
|
4
|
+
data.tar.gz: 8430bd95b51e2f00dd57976d963fa60bb0d82e334951349be32f0a54f3a0aa1c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 59212029fa16618b83b11a9f3e9a5d32feac79c6aa9d017333c6b652d39edb72080efdab2020d5b0ce5b969ca0ca23ca2dfeb846d83f91883bd7d4c024004ac5
|
|
7
|
+
data.tar.gz: d0a3d418eac306dba55a2aa4d5ef605e31f1ac4fa5d2a87adcc0d2c298b374b90b724df88e61910b18aa965e9b76105113164aedf1943200d5b77e0c576d8d26
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
data/lib/cmfrec/data.rb
CHANGED
|
@@ -54,9 +54,7 @@ module Cmfrec
|
|
|
54
54
|
|
|
55
55
|
def download_file(fname, origin, file_hash:)
|
|
56
56
|
require "digest"
|
|
57
|
-
require "
|
|
58
|
-
require "net/http"
|
|
59
|
-
require "tmpdir"
|
|
57
|
+
require "open-uri"
|
|
60
58
|
|
|
61
59
|
cache_home = ENV["XDG_CACHE_HOME"] || "#{ENV.fetch("HOME")}/.cache"
|
|
62
60
|
dest = "#{cache_home}/cmfrec/#{fname}"
|
|
@@ -64,38 +62,24 @@ module Cmfrec
|
|
|
64
62
|
|
|
65
63
|
return dest if File.exist?(dest)
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
# and deflateresponses unless a Range header was sent.
|
|
76
|
-
# https://ruby-doc.org/stdlib-2.6.4/libdoc/net/http/rdoc/Net/HTTP.html
|
|
77
|
-
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |http|
|
|
78
|
-
request = Net::HTTP::Get.new(uri)
|
|
79
|
-
|
|
80
|
-
puts "Downloading data from #{origin}"
|
|
81
|
-
File.open(temp_path, "wb") do |f|
|
|
82
|
-
http.request(request) do |response|
|
|
83
|
-
response.read_body do |chunk|
|
|
84
|
-
f.write(chunk)
|
|
85
|
-
digest.update(chunk)
|
|
86
|
-
end
|
|
65
|
+
puts "Downloading data from #{origin}"
|
|
66
|
+
URI.parse(origin).open(redirect: false) do |download|
|
|
67
|
+
digest =
|
|
68
|
+
if download.respond_to?(:path)
|
|
69
|
+
download.flush
|
|
70
|
+
Digest::SHA256.file(download.path).hexdigest
|
|
71
|
+
else
|
|
72
|
+
Digest::SHA256.hexdigest(download.string)
|
|
87
73
|
end
|
|
74
|
+
|
|
75
|
+
if digest != file_hash
|
|
76
|
+
raise Error, "Bad hash: #{digest}"
|
|
88
77
|
end
|
|
89
|
-
|
|
78
|
+
puts "Hash verified: #{file_hash}"
|
|
90
79
|
|
|
91
|
-
|
|
92
|
-
raise Error, "Bad hash: #{digest.hexdigest}"
|
|
80
|
+
IO.copy_stream(download, dest)
|
|
93
81
|
end
|
|
94
82
|
|
|
95
|
-
puts "Hash verified: #{file_hash}"
|
|
96
|
-
|
|
97
|
-
FileUtils.mv(temp_path, dest)
|
|
98
|
-
|
|
99
83
|
dest
|
|
100
84
|
end
|
|
101
85
|
end
|
data/lib/cmfrec/recommender.rb
CHANGED
|
@@ -158,10 +158,10 @@ module Cmfrec
|
|
|
158
158
|
@lambda_, @l1_lambda, @alpha, @w_main, @w_user,
|
|
159
159
|
@w_main_multiplier,
|
|
160
160
|
@apply_log_transf,
|
|
161
|
-
nil, #BeTBe
|
|
162
|
-
nil, #BtB
|
|
163
|
-
nil, #BeTBeChol
|
|
164
|
-
nil, #CtUbias
|
|
161
|
+
nil, # BeTBe
|
|
162
|
+
nil, # BtB
|
|
163
|
+
nil, # BeTBeChol
|
|
164
|
+
nil, # CtUbias
|
|
165
165
|
include_ix, n_include,
|
|
166
166
|
exclude_ix, n_exclude,
|
|
167
167
|
outp_ix, outp_score,
|
|
@@ -194,15 +194,15 @@ module Cmfrec
|
|
|
194
194
|
@scale_bias_const, scaling_bias_a,
|
|
195
195
|
@w_main, @w_user, @w_implicit,
|
|
196
196
|
n_max, @include_all_x,
|
|
197
|
-
nil, #BtB
|
|
198
|
-
nil, #TransBtBinvBt
|
|
199
|
-
nil, #BtXbias
|
|
200
|
-
nil, #BeTBeChol
|
|
201
|
-
nil, #BiTBi
|
|
202
|
-
nil, #CtCw
|
|
203
|
-
nil, #TransCtCinvCt
|
|
204
|
-
nil, #CtUbias
|
|
205
|
-
nil, #B_plus_bias
|
|
197
|
+
nil, # BtB
|
|
198
|
+
nil, # TransBtBinvBt
|
|
199
|
+
nil, # BtXbias
|
|
200
|
+
nil, # BeTBeChol
|
|
201
|
+
nil, # BiTBi
|
|
202
|
+
nil, # CtCw
|
|
203
|
+
nil, # TransCtCinvCt
|
|
204
|
+
nil, # CtUbias
|
|
205
|
+
nil, # B_plus_bias
|
|
206
206
|
include_ix, n_include,
|
|
207
207
|
exclude_ix, n_exclude,
|
|
208
208
|
outp_ix, outp_score,
|
|
@@ -275,7 +275,7 @@ module Cmfrec
|
|
|
275
275
|
# mean
|
|
276
276
|
obj[:global_mean] = @global_mean
|
|
277
277
|
|
|
278
|
-
unless (@user_info_map.keys + @item_info_map.keys).all?
|
|
278
|
+
unless (@user_info_map.keys + @item_info_map.keys).all?(Symbol)
|
|
279
279
|
raise "Side info keys must be symbols to save"
|
|
280
280
|
end
|
|
281
281
|
|
|
@@ -449,10 +449,10 @@ module Cmfrec
|
|
|
449
449
|
@use_cg, @max_cg_steps, @precondition_cg, @finalize_chol,
|
|
450
450
|
@nonneg, @max_cd_steps, @nonneg_c, @nonneg_d,
|
|
451
451
|
@precompute_for_predictions,
|
|
452
|
-
nil, #precomputedBtB
|
|
453
|
-
nil, #precomputedBeTBe
|
|
454
|
-
nil, #precomputedBeTBeChol
|
|
455
|
-
nil #precomputedCtUbias
|
|
452
|
+
nil, # precomputedBtB
|
|
453
|
+
nil, # precomputedBeTBe
|
|
454
|
+
nil, # precomputedBeTBeChol
|
|
455
|
+
nil # precomputedCtUbias
|
|
456
456
|
]
|
|
457
457
|
check_status FFI.fit_collective_implicit_als(*fiddle_args(args))
|
|
458
458
|
|
|
@@ -505,15 +505,15 @@ module Cmfrec
|
|
|
505
505
|
@nonneg, @max_cd_steps, @nonneg_c, @nonneg_d,
|
|
506
506
|
@precompute_for_predictions,
|
|
507
507
|
@include_all_x,
|
|
508
|
-
nil, #B_plus_bias
|
|
509
|
-
nil, #precomputedBtB
|
|
510
|
-
nil, #precomputedTransBtBinvBt
|
|
511
|
-
nil, #precomputedBtXbias
|
|
512
|
-
nil, #precomputedBeTBeChol
|
|
513
|
-
nil, #precomputedBiTBi
|
|
514
|
-
nil, #precomputedTransCtCinvCt
|
|
515
|
-
nil, #precomputedCtCw
|
|
516
|
-
nil #precomputedCtUbias
|
|
508
|
+
nil, # B_plus_bias
|
|
509
|
+
nil, # precomputedBtB
|
|
510
|
+
nil, # precomputedTransBtBinvBt
|
|
511
|
+
nil, # precomputedBtXbias
|
|
512
|
+
nil, # precomputedBeTBeChol
|
|
513
|
+
nil, # precomputedBiTBi
|
|
514
|
+
nil, # precomputedTransCtCinvCt
|
|
515
|
+
nil, # precomputedCtCw
|
|
516
|
+
nil # precomputedCtUbias
|
|
517
517
|
]
|
|
518
518
|
check_status FFI.fit_collective_explicit_als(*fiddle_args(args))
|
|
519
519
|
|
|
@@ -604,7 +604,7 @@ module Cmfrec
|
|
|
604
604
|
unless ratings.all? { |r| !r.nil? }
|
|
605
605
|
raise ArgumentError, "Missing ratings"
|
|
606
606
|
end
|
|
607
|
-
unless ratings.all?
|
|
607
|
+
unless ratings.all?(Numeric)
|
|
608
608
|
raise ArgumentError, "Ratings must be numeric"
|
|
609
609
|
end
|
|
610
610
|
end
|
|
@@ -660,7 +660,7 @@ module Cmfrec
|
|
|
660
660
|
def prepare_top_n(count: nil, rated: nil, item_ids: nil)
|
|
661
661
|
if item_ids
|
|
662
662
|
# remove missing ids
|
|
663
|
-
item_ids = item_ids.
|
|
663
|
+
item_ids = item_ids.filter_map { |v| @item_map[v] }
|
|
664
664
|
return [] if item_ids.empty?
|
|
665
665
|
|
|
666
666
|
include_ix = int_ptr(item_ids)
|
data/lib/cmfrec/version.rb
CHANGED
data/lib/cmfrec.rb
CHANGED
|
@@ -25,7 +25,11 @@ module Cmfrec
|
|
|
25
25
|
"x86_64-darwin/libcmfrec.dylib"
|
|
26
26
|
end
|
|
27
27
|
else
|
|
28
|
-
"
|
|
28
|
+
if RbConfig::CONFIG["host_cpu"] =~ /arm|aarch64/i
|
|
29
|
+
"aarch64-linux/libcmfrec.so"
|
|
30
|
+
else
|
|
31
|
+
"x86_64-linux/libcmfrec.so"
|
|
32
|
+
end
|
|
29
33
|
end
|
|
30
34
|
vendor_lib = File.expand_path("../vendor/#{lib_path}", __dir__)
|
|
31
35
|
self.ffi_lib = [vendor_lib]
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
For the included LFBGS library (files "lbfgs.h", "lbfgs.c", "arithmetic_ansi.h"):
|
|
2
|
+
|
|
3
|
+
The MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 1990 Jorge Nocedal
|
|
6
|
+
Copyright (c) 2007-2010 Naoaki Okazaki
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
9
|
+
copy of this software and associated documentation files (the "Software"),
|
|
10
|
+
to deal in the Software without restriction, including without limitation
|
|
11
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
|
13
|
+
Software is furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in
|
|
16
|
+
all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
THE SOFTWARE.
|
|
25
|
+
|
|
26
|
+
For the included ziggurat tables (file "ziggurat.h"):
|
|
27
|
+
|
|
28
|
+
Copyright (c) 2005-2022, NumPy Developers.
|
|
29
|
+
All rights reserved.
|
|
30
|
+
|
|
31
|
+
Redistribution and use in source and binary forms, with or without
|
|
32
|
+
modification, are permitted provided that the following conditions are
|
|
33
|
+
met:
|
|
34
|
+
|
|
35
|
+
* Redistributions of source code must retain the above copyright
|
|
36
|
+
notice, this list of conditions and the following disclaimer.
|
|
37
|
+
|
|
38
|
+
* Redistributions in binary form must reproduce the above
|
|
39
|
+
copyright notice, this list of conditions and the following
|
|
40
|
+
disclaimer in the documentation and/or other materials provided
|
|
41
|
+
with the distribution.
|
|
42
|
+
|
|
43
|
+
* Neither the name of the NumPy Developers nor the names of any
|
|
44
|
+
contributors may be used to endorse or promote products derived
|
|
45
|
+
from this software without specific prior written permission.
|
|
46
|
+
|
|
47
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
48
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
49
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
50
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
51
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
52
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
53
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
54
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
55
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
56
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
57
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020-2022 David Cortes
|
|
4
|
+
|
|
5
|
+
All rights reserved.
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to
|
|
9
|
+
deal in the Software without restriction, including without limitation the
|
|
10
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
11
|
+
sell copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
22
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
23
|
+
IN THE SOFTWARE.
|
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cmfrec
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Kane
|
|
@@ -36,6 +36,9 @@ files:
|
|
|
36
36
|
- lib/cmfrec/ffi.rb
|
|
37
37
|
- lib/cmfrec/recommender.rb
|
|
38
38
|
- lib/cmfrec/version.rb
|
|
39
|
+
- vendor/aarch64-linux/COPYRIGHTS
|
|
40
|
+
- vendor/aarch64-linux/LICENSE
|
|
41
|
+
- vendor/aarch64-linux/libcmfrec.so
|
|
39
42
|
- vendor/arm64-darwin/COPYRIGHTS
|
|
40
43
|
- vendor/arm64-darwin/LICENSE
|
|
41
44
|
- vendor/arm64-darwin/libcmfrec.dylib
|
|
@@ -56,14 +59,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
56
59
|
requirements:
|
|
57
60
|
- - ">="
|
|
58
61
|
- !ruby/object:Gem::Version
|
|
59
|
-
version: '3.
|
|
62
|
+
version: '3.3'
|
|
60
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
64
|
requirements:
|
|
62
65
|
- - ">="
|
|
63
66
|
- !ruby/object:Gem::Version
|
|
64
67
|
version: '0'
|
|
65
68
|
requirements: []
|
|
66
|
-
rubygems_version:
|
|
69
|
+
rubygems_version: 4.0.6
|
|
67
70
|
specification_version: 4
|
|
68
71
|
summary: Recommendations for Ruby using collective matrix factorization
|
|
69
72
|
test_files: []
|