libmf 0.3.0 → 0.4.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: 510156ab4bccb39a99441002dd80f3540b643934294bc5724dca91987b4effba
4
- data.tar.gz: 03a1f04e4679ec60cb2f1d2a96e2add0b9adba03fe5715bc4f10309ab795bcc1
3
+ metadata.gz: b264767ceb43c4a0407896e2bcf2373a47296e1e0580c65ec2ef08471589f661
4
+ data.tar.gz: addfb47cc44989620f847eac0392aef7431e596af08095ddd56ed227c4b99274
5
5
  SHA512:
6
- metadata.gz: eb862c0cf91a077ba2e9a0ed3f93491297cdc9801683e3587b91125c7e0b79123d0f942aea6bf3cef42fbbb43f5e8f822758a894f25a7eedf2fd9ee7b5ea4920
7
- data.tar.gz: b4d74a6b3d4160f3b1165f90496a9f93c6b59ca99e5f3cc0094f022a0807fc8a34af3d9b0edeeff463264a60c19901ceaa171c3cea944d860103208e2d26dbf2
6
+ metadata.gz: b22bcab875b5c2e8b7432c137f90b3ea37a8c16c3e64aa0fb4c15f824f8345a3105ca981a4ea1ea091396dcd0ce10320eab52f56e6ede75601ea2192e5bc61ac
7
+ data.tar.gz: 2e946522f35f77a46ab3880d74da38a0efdcaf432eabc1945d35af344d5cafb2c7712a3e0660352f8cf84fbd44af5c9c4e1cc6110ef5b908cd66c3393e124a99
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.4.0 (2024-10-22)
2
+
3
+ - Dropped support for Ruby < 3.1
4
+
1
5
  ## 0.3.0 (2022-08-07)
2
6
 
3
7
  - Added metrics
data/LICENSE.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  BSD 3-Clause License
2
2
 
3
3
  Copyright (c) 2014-2015 The LIBMF Project.
4
- Copyright (c) 2019-2022 Andrew Kane.
4
+ Copyright (c) 2019-2024 Andrew Kane.
5
5
  All rights reserved.
6
6
 
7
7
  Redistribution and use in source and binary forms, with or without
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Check out [Disco](https://github.com/ankane/disco) for higher-level collaborative filtering
6
6
 
7
- [![Build Status](https://github.com/ankane/libmf-ruby/workflows/build/badge.svg?branch=master)](https://github.com/ankane/libmf-ruby/actions)
7
+ [![Build Status](https://github.com/ankane/libmf-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/libmf-ruby/actions)
8
8
 
9
9
  ## Installation
10
10
 
@@ -170,6 +170,27 @@ Calculate AUC (for one-class MF)
170
170
  model.auc(data, transpose)
171
171
  ```
172
172
 
173
+ ## Example
174
+
175
+ Download the [MovieLens 100K dataset](https://grouplens.org/datasets/movielens/100k/) and use:
176
+
177
+ ```ruby
178
+ require "csv"
179
+
180
+ train_set = Libmf::Matrix.new
181
+ valid_set = Libmf::Matrix.new
182
+
183
+ CSV.foreach("u.data", col_sep: "\t").with_index do |row, i|
184
+ data = i < 80000 ? train_set : valid_set
185
+ data.push(row[0].to_i, row[1].to_i, row[2].to_f)
186
+ end
187
+
188
+ model = Libmf::Model.new(factors: 20)
189
+ model.fit(train_set, eval_set: valid_set)
190
+
191
+ puts model.rmse(valid_set)
192
+ ```
193
+
173
194
  ## Performance
174
195
 
175
196
  For performance, read data directly from files
data/lib/libmf/model.rb CHANGED
@@ -141,13 +141,13 @@ module Libmf
141
141
  options[:bins] ||= 25 unless options[:nr_bins]
142
142
  options[:copy_data] = false unless options.key?(:copy_data)
143
143
  options_map = {
144
- :loss => :fun,
145
- :factors => :k,
146
- :threads => :nr_threads,
147
- :bins => :nr_bins,
148
- :iterations => :nr_iters,
149
- :learning_rate => :eta,
150
- :nmf => :do_nmf
144
+ loss: :fun,
145
+ factors: :k,
146
+ threads: :nr_threads,
147
+ bins: :nr_bins,
148
+ iterations: :nr_iters,
149
+ learning_rate: :eta,
150
+ nmf: :do_nmf
151
151
  }
152
152
  options.each do |k, v|
153
153
  k = options_map[k] if options_map[k]
data/lib/libmf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Libmf
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/libmf.rb CHANGED
@@ -2,9 +2,9 @@
2
2
  require "ffi"
3
3
 
4
4
  # modules
5
- require "libmf/matrix"
6
- require "libmf/model"
7
- require "libmf/version"
5
+ require_relative "libmf/matrix"
6
+ require_relative "libmf/model"
7
+ require_relative "libmf/version"
8
8
 
9
9
  module Libmf
10
10
  class Error < StandardError; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libmf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.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: 2022-08-08 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: ffi
@@ -58,14 +58,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '2.7'
61
+ version: '3.1'
62
62
  required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - ">="
65
65
  - !ruby/object:Gem::Version
66
66
  version: '0'
67
67
  requirements: []
68
- rubygems_version: 3.3.7
68
+ rubygems_version: 3.5.16
69
69
  signing_key:
70
70
  specification_version: 4
71
71
  summary: Large-scale sparse matrix factorization for Ruby