disco 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbc2c36a98486f496c7c5aed996b3250def9f87ce444dc48e4f8c9164db9e630
4
- data.tar.gz: a862bf6d66484f5dac154586dea0a89d85a4873644ff00f4420ac3dfc0c9a852
3
+ metadata.gz: ffa944ca55d7da5a4dc4cced181d013a9fdc0f1fbb76af6003ba3049bb299682
4
+ data.tar.gz: 64f389a3a93173b3d24cad85e5072b4d3f8965a729387a5845ed9c86098a9496
5
5
  SHA512:
6
- metadata.gz: 948d564359a61c1ad356c0806e34c57d6dcae354cc55cf1bff4bce5f40ee94b37edd3c5d8fc35e36cb0aeae59ee467acb561c0074bbb7fb8da929b7e548bcf1f
7
- data.tar.gz: f3d98a62dd540957343a29c01624586e853a0f400f8105d2ae67d34e85e408b652befc0d702720e4d7e33852ac738b2a8e276acb6ac143195620386b07e99084
6
+ metadata.gz: f167237c7553d5a506467844d6acf860e81efca11da4e8facb8988cc994fbe70a52b38ff87b0d1157bcf9312b172c8794b49e6e8607748f77b129bcac26742d2
7
+ data.tar.gz: f5feab5c5d88dac8cc5a01cbab437110d0fe41c4fa98283464174d253996d8c8efa9dc92724f30bbae334c7fe2c7cb932b2b6335bd37f44aa645ef33fa7ec7ea
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.5.0 (2024-10-22)
2
+
3
+ - Changed dataset directory to match XDG Base Directory Specification
4
+ - Dropped support for marshal serialization
5
+ - Dropped support for Ruby < 3.1 and Rails < 7
6
+
1
7
  ## 0.4.2 (2024-06-24)
2
8
 
3
9
  - Removed dependency on `csv` gem for `load_movielens`
data/README.md CHANGED
@@ -194,7 +194,7 @@ json = File.read("recommender.json")
194
194
  recommender = Disco::Recommender.load_json(json)
195
195
  ```
196
196
 
197
- Alternatively, you can store only the factors and use a library like [Neighbor](https://github.com/ankane/neighbor). See the [examples](https://github.com/ankane/neighbor/tree/master/examples).
197
+ Alternatively, you can store only the factors and use a library like [Neighbor](https://github.com/ankane/neighbor). See the [examples](https://github.com/ankane/neighbor/tree/master/examples/disco).
198
198
 
199
199
  ## Algorithms
200
200
 
data/lib/disco/data.rb CHANGED
@@ -33,9 +33,8 @@ module Disco
33
33
  require "net/http"
34
34
  require "tmpdir"
35
35
 
36
- # TODO handle this better
37
- raise "No HOME" unless ENV["HOME"]
38
- dest = "#{ENV["HOME"]}/.disco/#{fname}"
36
+ cache_home = ENV["XDG_CACHE_HOME"] || "#{ENV.fetch("HOME")}/.cache"
37
+ dest = "#{cache_home}/disco/#{fname}"
39
38
  FileUtils.mkdir_p(File.dirname(dest))
40
39
 
41
40
  return dest if File.exist?(dest)
data/lib/disco/model.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Disco
2
2
  module Model
3
3
  def has_recommended(name, class_name: nil)
4
- if ActiveRecord::VERSION::MAJOR < 6
5
- raise Disco::Error, "Requires Active Record 6+"
4
+ if ActiveRecord::VERSION::MAJOR < 7
5
+ raise Disco::Error, "Requires Active Record 7+"
6
6
  end
7
7
 
8
8
  class_name ||= name.to_s.singularize.camelize
@@ -64,8 +64,8 @@ module Disco
64
64
  end
65
65
 
66
66
  if @top_items
67
- @item_count = [0] * @item_map.size
68
- @item_sum = [0.0] * @item_map.size
67
+ @item_count = Array.new(@item_map.size, 0)
68
+ @item_sum = Array.new(@item_map.size, 0.0)
69
69
  train_set.each do |v|
70
70
  i = @item_map[v[:item_id]]
71
71
  @item_count[i] += 1
@@ -431,61 +431,6 @@ module Disco
431
431
  end
432
432
  end
433
433
 
434
- def marshal_dump
435
- warn "[disco] Marshal serialization is deprecated - use JSON instead"
436
-
437
- obj = {
438
- implicit: @implicit,
439
- user_map: @user_map,
440
- item_map: @item_map,
441
- rated: @rated,
442
- global_mean: @global_mean,
443
- user_factors: @user_factors,
444
- item_factors: @item_factors,
445
- factors: @factors,
446
- epochs: @epochs,
447
- verbose: @verbose
448
- }
449
-
450
- unless @implicit
451
- obj[:min_rating] = @min_rating
452
- obj[:max_rating] = @max_rating
453
- end
454
-
455
- if @top_items
456
- obj[:item_count] = @item_count
457
- obj[:item_sum] = @item_sum
458
- end
459
-
460
- obj
461
- end
462
-
463
- def marshal_load(obj)
464
- warn "[disco] Marshal serialization is deprecated - use JSON instead"
465
-
466
- @implicit = obj[:implicit]
467
- @user_map = obj[:user_map]
468
- @item_map = obj[:item_map]
469
- @rated = obj[:rated]
470
- @global_mean = obj[:global_mean]
471
- @user_factors = obj[:user_factors]
472
- @item_factors = obj[:item_factors]
473
- @factors = obj[:factors]
474
- @epochs = obj[:epochs]
475
- @verbose = obj[:verbose]
476
-
477
- unless @implicit
478
- @min_rating = obj[:min_rating]
479
- @max_rating = obj[:max_rating]
480
- end
481
-
482
- @top_items = obj.key?(:item_count)
483
- if @top_items
484
- @item_count = obj[:item_count]
485
- @item_sum = obj[:item_sum]
486
- end
487
- end
488
-
489
434
  def json_load(obj)
490
435
  require "base64"
491
436
 
data/lib/disco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Disco
2
- VERSION = "0.4.2"
2
+ VERSION = "0.5.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.4.2
4
+ version: 0.5.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: 2024-06-24 00:00:00.000000000 Z
11
+ date: 2024-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libmf
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.2'
19
+ version: '0.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0.2'
26
+ version: '0.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: numo-narray
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 0.9.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 0.9.2
41
41
  description:
42
42
  email: andrew@ankane.org
43
43
  executables: []
@@ -69,14 +69,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
69
  requirements:
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
- version: '2.7'
72
+ version: '3.1'
73
73
  required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - ">="
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  requirements: []
79
- rubygems_version: 3.5.11
79
+ rubygems_version: 3.5.16
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Recommendations for Ruby and Rails using collaborative filtering