numo-libsvm 2.1.0 → 2.2.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: 37613a10119b2974024687c3f781d271ebaa30b15ccff6100df17c32642dcd2d
4
- data.tar.gz: 210e072576d4fa859364fdb522e6f02c9be12458e5ed0647fcd8bebedfdb3e84
3
+ metadata.gz: 1e4eb5d7c2a7e1bde6c1987e2f235d66954715d13c894b732f45686c944f632b
4
+ data.tar.gz: 1a2839e141f0160328aaae9cbd7e2b85f4bf500f880dbbc94599c2568fb04e27
5
5
  SHA512:
6
- metadata.gz: 142e15fe744460f679f7bd7978f1654e2e71a40a49ce3a414c3c0e68b507d6d9c286eec9edd37a10f5b9fc60a940079c42e59d1283ba607cd7748b80d16fa12f
7
- data.tar.gz: 67909b309d9a186e77dc716cc2e8b1299d0be3baf10be7be87fc89f2bc67a47b087063827be2f8ba750378d354f745c58dec0feb072f8eea73c883c3c034a669
6
+ metadata.gz: 7f115624dc61595a4bc6298c055e4a0a3bbecd12aad2645b8c2869fd62d036f0d874a6884ec351b589f4acb315ff09d58dc6e4a0df71cd992bc9cf8d96e07ab8
7
+ data.tar.gz: cd04639c40579d3f1aa2ba88ddf62e1510cd7d1b7f224acd04866eaf075bede38063ecb84b018cc3f0bcd7831f6a5c26149f8221abbe31b6d50d4e06a24268ef
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 2.2.0
2
+ - Update bundled LIBSVM to 3.31.
3
+
4
+ # 2.1.1
5
+ - Fix build failure with Xcode 14 and Ruby 3.1.x.
6
+
1
7
  # 2.1.0
2
8
  - Update bundled LIBSVM to 3.30.
3
9
  - Support for probilistic outputs of one-class SVM.
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2019-2022 Atsushi Tatsuma
1
+ Copyright (c) 2019-2023 Atsushi Tatsuma
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
@@ -20,6 +20,12 @@ if RUBY_PLATFORM =~ /mswin|cygwin|mingw/
20
20
  abort 'libnarray.a not found.' unless have_library('narray', 'nary_new')
21
21
  end
22
22
 
23
+ if RUBY_PLATFORM.match?(/darwin/) && Gem::Version.new('3.1.0') <= Gem::Version.new(RUBY_VERSION)
24
+ if try_link('int main(void){return 0;}', '-Wl,-undefined,dynamic_lookup')
25
+ $LDFLAGS << ' -Wl,-undefined,dynamic_lookup'
26
+ end
27
+ end
28
+
23
29
  abort 'libstdc++ is not found.' unless have_library('stdc++')
24
30
 
25
31
  $srcs = Dir.glob("#{$srcdir}/**/*.cpp").map { |path| File.basename(path) }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2019-2022 Atsushi Tatsuma
2
+ * Copyright (c) 2019-2023 Atsushi Tatsuma
3
3
  * All rights reserved.
4
4
  *
5
5
  * Redistribution and use in source and binary forms, with or without
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2019-2022 Atsushi Tatsuma
2
+ * Copyright (c) 2019-2023 Atsushi Tatsuma
3
3
  * All rights reserved.
4
4
  *
5
5
  * Redistribution and use in source and binary forms, with or without
@@ -1,5 +1,5 @@
1
1
 
2
- Copyright (c) 2000-2019 Chih-Chung Chang and Chih-Jen Lin
2
+ Copyright (c) 2000-2023 Chih-Chung Chang and Chih-Jen Lin
3
3
  All rights reserved.
4
4
 
5
5
  Redistribution and use in source and binary forms, with or without
@@ -8,6 +8,10 @@
8
8
  #include <limits.h>
9
9
  #include <locale.h>
10
10
  #include "svm.h"
11
+ #ifdef _OPENMP
12
+ #include <omp.h>
13
+ #endif
14
+
11
15
  int libsvm_version = LIBSVM_VERSION;
12
16
  typedef float Qfloat;
13
17
  typedef signed char schar;
@@ -1282,6 +1286,9 @@ public:
1282
1286
  int start, j;
1283
1287
  if((start = cache->get_data(i,&data,len)) < len)
1284
1288
  {
1289
+ #ifdef _OPENMP
1290
+ #pragma omp parallel for private(j) schedule(guided)
1291
+ #endif
1285
1292
  for(j=start;j<len;j++)
1286
1293
  data[j] = (Qfloat)(y[i]*y[j]*(this->*kernel_function)(i,j));
1287
1294
  }
@@ -1397,6 +1404,9 @@ public:
1397
1404
  int j, real_i = index[i];
1398
1405
  if(cache->get_data(real_i,&data,l) < l)
1399
1406
  {
1407
+ #ifdef _OPENMP
1408
+ #pragma omp parallel for private(j) schedule(guided)
1409
+ #endif
1400
1410
  for(j=0;j<l;j++)
1401
1411
  data[j] = (Qfloat)(this->*kernel_function)(real_i,j);
1402
1412
  }
@@ -2219,11 +2229,9 @@ svm_model *svm_train(const svm_problem *prob, const svm_parameter *param)
2219
2229
  double *prob_density_marks = Malloc(double,nr_marks);
2220
2230
 
2221
2231
  if(svm_one_class_probability(prob,model,prob_density_marks) == 0)
2222
- {
2223
- model->prob_density_marks = Malloc(double,nr_marks);
2224
- for(i=0;i<nr_marks;i++)
2225
- model->prob_density_marks[i] = prob_density_marks[i];
2226
- }
2232
+ model->prob_density_marks = prob_density_marks;
2233
+ else
2234
+ free(prob_density_marks);
2227
2235
  }
2228
2236
 
2229
2237
  free(f.alpha);
@@ -2436,8 +2444,8 @@ void svm_cross_validation(const svm_problem *prob, const svm_parameter *param, i
2436
2444
  int nr_class;
2437
2445
  if (nr_fold > l)
2438
2446
  {
2447
+ fprintf(stderr,"WARNING: # folds (%d) > # data (%d). Will use # folds = # data instead (i.e., leave-one-out cross validation)\n", nr_fold, l);
2439
2448
  nr_fold = l;
2440
- fprintf(stderr,"WARNING: # folds > # data. Will use # folds = # data instead (i.e., leave-one-out cross validation)\n");
2441
2449
  }
2442
2450
  fold_start = Malloc(int,nr_fold+1);
2443
2451
  // stratified cv may not give leave-one-out rate
@@ -2598,6 +2606,9 @@ double svm_predict_values(const svm_model *model, const svm_node *x, double* dec
2598
2606
  {
2599
2607
  double *sv_coef = model->sv_coef[0];
2600
2608
  double sum = 0;
2609
+ #ifdef _OPENMP
2610
+ #pragma omp parallel for private(i) reduction(+:sum) schedule(guided)
2611
+ #endif
2601
2612
  for(i=0;i<model->l;i++)
2602
2613
  sum += sv_coef[i] * Kernel::k_function(x,model->SV[i],model->param);
2603
2614
  sum -= model->rho[0];
@@ -2614,6 +2625,9 @@ double svm_predict_values(const svm_model *model, const svm_node *x, double* dec
2614
2625
  int l = model->l;
2615
2626
 
2616
2627
  double *kvalue = Malloc(double,l);
2628
+ #ifdef _OPENMP
2629
+ #pragma omp parallel for private(i) schedule(guided)
2630
+ #endif
2617
2631
  for(i=0;i<l;i++)
2618
2632
  kvalue[i] = Kernel::k_function(x,model->SV[i],model->param);
2619
2633
 
@@ -1,7 +1,7 @@
1
1
  #ifndef _LIBSVM_H
2
2
  #define _LIBSVM_H
3
3
 
4
- #define LIBSVM_VERSION 330
4
+ #define LIBSVM_VERSION 331
5
5
 
6
6
  #ifdef __cplusplus
7
7
  extern "C" {
@@ -3,6 +3,6 @@
3
3
  module Numo
4
4
  module Libsvm
5
5
  # The version of Numo::Libsvm you are using.
6
- VERSION = '2.1.0'
6
+ VERSION = '2.2.0'
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numo-libsvm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshoku
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-03 00:00:00.000000000 Z
11
+ date: 2023-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: numo-narray
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
73
  requirements: []
74
- rubygems_version: 3.2.33
74
+ rubygems_version: 3.3.26
75
75
  signing_key:
76
76
  specification_version: 4
77
77
  summary: Numo::Libsvm is a Ruby gem binding to the LIBSVM library. Numo::Libsvm makes