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 +4 -4
- data/CHANGELOG.md +4 -0
- data/LICENSE.txt +1 -1
- data/README.md +22 -1
- data/lib/libmf/model.rb +7 -7
- data/lib/libmf/version.rb +1 -1
- data/lib/libmf.rb +3 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b264767ceb43c4a0407896e2bcf2373a47296e1e0580c65ec2ef08471589f661
|
4
|
+
data.tar.gz: addfb47cc44989620f847eac0392aef7431e596af08095ddd56ed227c4b99274
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b22bcab875b5c2e8b7432c137f90b3ea37a8c16c3e64aa0fb4c15f824f8345a3105ca981a4ea1ea091396dcd0ce10320eab52f56e6ede75601ea2192e5bc61ac
|
7
|
+
data.tar.gz: 2e946522f35f77a46ab3880d74da38a0efdcaf432eabc1945d35af344d5cafb2c7712a3e0660352f8cf84fbd44af5c9c4e1cc6110ef5b908cd66c3393e124a99
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
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
|
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
|
-
:
|
145
|
-
:
|
146
|
-
:
|
147
|
-
:
|
148
|
-
:
|
149
|
-
:
|
150
|
-
:
|
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
data/lib/libmf.rb
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
require "ffi"
|
3
3
|
|
4
4
|
# modules
|
5
|
-
|
6
|
-
|
7
|
-
|
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.
|
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:
|
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: '
|
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.
|
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
|