libffm 0.1.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d83d396ee32f053d336ee05dd5eb5091f5c45e2638efb5accd6968cf95cab1b0
4
- data.tar.gz: 7417b2812bce94a06a92f580d2aca82b34e4298c23c548a5ba6a556d7d148c96
3
+ metadata.gz: 5f1d48f6ab534406f57b25e461c3dadda4811b058c4ece588b27670eef6313b6
4
+ data.tar.gz: 3991527073b513ce0104861539cd7f62200282891fd1b7631648936572b9adc6
5
5
  SHA512:
6
- metadata.gz: 6a73888faced817a7c4b6d3095611ea42f711853d19c3edb43688a7b39b7aad144b1ee27efe13683834569dbcfc564a49a7ceafbb86d5246e9f8fdb5a038e7a6
7
- data.tar.gz: 12196508c774adc8b25bf91755dacf4208537a3aa1c19695a1b9f4405790c989291903a5402a59ed9650614173a551f306439f15aae69477d15bd148eaf91441
6
+ metadata.gz: 1939d2d1cbb8180cb4ebc351c3f831da8204e07ee073bbb84e8e50c80b71cde01ae48e1d6a67c2ade3a32b05e003b2a0ad9295645eeaf918b0f76ac19f0cfd59
7
+ data.tar.gz: d4717dae8844e43a2e3c2cc8889713de452f7e9e9781e1647072033336b03ee52ffd869e5e5a98c2c1d098fc35d6e0e34e41de9db80a20abcda11e14afefb67d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.2.0 (2021-05-17)
2
+
3
+ - Updated to Rice 4
4
+ - Dropped support for Ruby < 2.6
5
+
1
6
  ## 0.1.1 (2020-11-28)
2
7
 
3
8
  - Fixed installation on Linux
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  Copyright (c) 2017 The LIBFFM Project.
3
- Copyright (c) 2020 Andrew Kane.
3
+ Copyright (c) 2020-2021 Andrew Kane.
4
4
  All rights reserved.
5
5
 
6
6
  Redistribution and use in source and binary forms, with or without
data/ext/libffm/ext.cpp CHANGED
@@ -5,10 +5,8 @@
5
5
  #include <ffm.h>
6
6
 
7
7
  // rice
8
- #include <rice/Array.hpp>
9
- #include <rice/Class.hpp>
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
- .define_singleton_method(
29
+ .define_singleton_function(
32
30
  "release_model",
33
- *[](ffm::ffm_model& model) {
31
+ [](ffm::ffm_model& model) {
34
32
  model.release();
35
33
  })
36
- .define_singleton_method(
34
+ .define_singleton_function(
37
35
  "fit",
38
- *[](std::string tr_path, std::string va_path, 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) {
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
- .define_singleton_method(
59
+ .define_singleton_function(
62
60
  "predict",
63
- *[](ffm::ffm_model& model, std::string test_path) {
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
- .define_singleton_method(
98
+ .define_singleton_function(
101
99
  "save_model",
102
- *[](ffm::ffm_model& model, std::string path) {
100
+ [](ffm::ffm_model& model, const std::string& path) {
103
101
  ffm::ffm_save_model(model, path);
104
102
  })
105
- .define_singleton_method(
103
+ .define_singleton_function(
106
104
  "load_model",
107
- *[](std::string path) {
105
+ [](const std::string& path) {
108
106
  return ffm::ffm_load_model(path);
109
107
  });
110
108
  }
@@ -2,7 +2,7 @@ require "mkmf-rice"
2
2
 
3
3
  # -DUSESSE requires sse3
4
4
  # TODO test for it or update fork to use __SSE3__
5
- $CXXFLAGS += " -std=c++11 -march=native"
5
+ $CXXFLAGS += " -std=c++17 -march=native"
6
6
 
7
7
  apple_clang = RbConfig::CONFIG["CC_VERSION_MESSAGE"] =~ /apple clang/i
8
8
 
@@ -1,3 +1,3 @@
1
1
  module Libffm
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -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.1.1
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: 2020-11-29 00:00:00.000000000 Z
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: '2.2'
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: '2.2'
26
+ version: 4.0.2
27
27
  description:
28
- email: andrew@chartkick.com
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.5'
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.1.4
71
+ rubygems_version: 3.2.3
71
72
  signing_key:
72
73
  specification_version: 4
73
74
  summary: Field-aware factorization machines for Ruby