libffm 0.1.1 → 0.2.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 +5 -0
- data/LICENSE.txt +1 -1
- data/ext/libffm/ext.cpp +12 -14
- data/ext/libffm/extconf.rb +1 -1
- data/lib/libffm/version.rb +1 -1
- data/vendor/libffm/ffm.cpp +10 -0
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f1d48f6ab534406f57b25e461c3dadda4811b058c4ece588b27670eef6313b6
|
4
|
+
data.tar.gz: 3991527073b513ce0104861539cd7f62200282891fd1b7631648936572b9adc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1939d2d1cbb8180cb4ebc351c3f831da8204e07ee073bbb84e8e50c80b71cde01ae48e1d6a67c2ade3a32b05e003b2a0ad9295645eeaf918b0f76ac19f0cfd59
|
7
|
+
data.tar.gz: d4717dae8844e43a2e3c2cc8889713de452f7e9e9781e1647072033336b03ee52ffd869e5e5a98c2c1d098fc35d6e0e34e41de9db80a20abcda11e14afefb67d
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
data/ext/libffm/ext.cpp
CHANGED
@@ -5,10 +5,8 @@
|
|
5
5
|
#include <ffm.h>
|
6
6
|
|
7
7
|
// rice
|
8
|
-
#include <rice/
|
9
|
-
#include <rice/
|
10
|
-
#include <rice/Module.hpp>
|
11
|
-
#include <rice/Object.hpp>
|
8
|
+
#include <rice/rice.hpp>
|
9
|
+
#include <rice/stl.hpp>
|
12
10
|
|
13
11
|
using Rice::Array;
|
14
12
|
using Rice::Class;
|
@@ -28,14 +26,14 @@ void Init_ext()
|
|
28
26
|
define_class_under<ffm::ffm_model>(rb_mExt, "Model");
|
29
27
|
|
30
28
|
rb_mExt
|
31
|
-
.
|
29
|
+
.define_singleton_function(
|
32
30
|
"release_model",
|
33
|
-
|
31
|
+
[](ffm::ffm_model& model) {
|
34
32
|
model.release();
|
35
33
|
})
|
36
|
-
.
|
34
|
+
.define_singleton_function(
|
37
35
|
"fit",
|
38
|
-
|
36
|
+
[](const std::string& tr_path, const std::string& va_path, const std::string& tmp_prefix, ffm::ffm_float eta, ffm::ffm_float lambda, ffm::ffm_int nr_iters, ffm::ffm_int k, bool normalization, bool auto_stop) {
|
39
37
|
// quiet
|
40
38
|
ffm::cout.setstate(ffm::ios_base::badbit);
|
41
39
|
|
@@ -58,9 +56,9 @@ void Init_ext()
|
|
58
56
|
|
59
57
|
return ffm::ffm_train_on_disk(tr_bin_path, va_bin_path, param);
|
60
58
|
})
|
61
|
-
.
|
59
|
+
.define_singleton_function(
|
62
60
|
"predict",
|
63
|
-
|
61
|
+
[](ffm::ffm_model& model, const std::string& test_path) {
|
64
62
|
int const kMaxLineSize = 1000000;
|
65
63
|
|
66
64
|
FILE *f_in = fopen(test_path.c_str(), "r");
|
@@ -97,14 +95,14 @@ void Init_ext()
|
|
97
95
|
|
98
96
|
return ret;
|
99
97
|
})
|
100
|
-
.
|
98
|
+
.define_singleton_function(
|
101
99
|
"save_model",
|
102
|
-
|
100
|
+
[](ffm::ffm_model& model, const std::string& path) {
|
103
101
|
ffm::ffm_save_model(model, path);
|
104
102
|
})
|
105
|
-
.
|
103
|
+
.define_singleton_function(
|
106
104
|
"load_model",
|
107
|
-
|
105
|
+
[](const std::string& path) {
|
108
106
|
return ffm::ffm_load_model(path);
|
109
107
|
});
|
110
108
|
}
|
data/ext/libffm/extconf.rb
CHANGED
data/lib/libffm/version.rb
CHANGED
data/vendor/libffm/ffm.cpp
CHANGED
@@ -569,13 +569,23 @@ ffm_model ffm_train_on_disk(string tr_path, string va_path, ffm_parameter param)
|
|
569
569
|
|
570
570
|
vector<ffm_int> outer_order(prob.meta.num_blocks);
|
571
571
|
iota(outer_order.begin(), outer_order.end(), 0);
|
572
|
+
#if __cplusplus >= 201703L
|
573
|
+
std::random_device rd;
|
574
|
+
std::mt19937 g(rd());
|
575
|
+
std::shuffle(outer_order.begin(), outer_order.end(), g);
|
576
|
+
#else
|
572
577
|
random_shuffle(outer_order.begin(), outer_order.end());
|
578
|
+
#endif
|
573
579
|
for(auto blk : outer_order) {
|
574
580
|
ffm_int l = prob.load_block(blk);
|
575
581
|
|
576
582
|
vector<ffm_int> inner_order(l);
|
577
583
|
iota(inner_order.begin(), inner_order.end(), 0);
|
584
|
+
#if __cplusplus >= 201703L
|
585
|
+
std::shuffle(inner_order.begin(), inner_order.end(), g);
|
586
|
+
#else
|
578
587
|
random_shuffle(inner_order.begin(), inner_order.end());
|
588
|
+
#endif
|
579
589
|
|
580
590
|
#if defined USEOMP
|
581
591
|
#pragma omp parallel for schedule(static) reduction(+: loss)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libffm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
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:
|
11
|
+
date: 2021-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rice
|
@@ -16,18 +16,19 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.0.2
|
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:
|
26
|
+
version: 4.0.2
|
27
27
|
description:
|
28
|
-
email: andrew@
|
28
|
+
email: andrew@ankane.org
|
29
29
|
executables: []
|
30
|
-
extensions:
|
30
|
+
extensions:
|
31
|
+
- ext/libffm/extconf.rb
|
31
32
|
extra_rdoc_files: []
|
32
33
|
files:
|
33
34
|
- CHANGELOG.md
|
@@ -60,14 +61,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
60
61
|
requirements:
|
61
62
|
- - ">="
|
62
63
|
- !ruby/object:Gem::Version
|
63
|
-
version: '2.
|
64
|
+
version: '2.6'
|
64
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
66
|
requirements:
|
66
67
|
- - ">="
|
67
68
|
- !ruby/object:Gem::Version
|
68
69
|
version: '0'
|
69
70
|
requirements: []
|
70
|
-
rubygems_version: 3.
|
71
|
+
rubygems_version: 3.2.3
|
71
72
|
signing_key:
|
72
73
|
specification_version: 4
|
73
74
|
summary: Field-aware factorization machines for Ruby
|