isotree 0.1.5 → 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 +4 -4
- data/CHANGELOG.md +5 -0
- data/ext/isotree/ext.cpp +86 -64
- data/ext/isotree/extconf.rb +1 -1
- data/lib/isotree/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95dc93ac1b84a5a37539b335da0457955ee8868997a34a9c249f7c54927f4b04
|
4
|
+
data.tar.gz: eff22a02afce64167248e967d384b0c9b2259f2f5248cfad5bd37acd8bc44e2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f410b78af1ae72f4cd166511b6b676f3b71bc39ce92641c455879a3aa88172abb7d1c37ffc953d505fdd59db07d355c9ffba20c3577a1d9b2311c5959a4c87f
|
7
|
+
data.tar.gz: 4804ec4aa11997fb91bcd714a0569e0571970bf06d4ad9b491f0e450c33183c86d37a922577ec296765708e9599272863cfa7f775f7dca4d9d18346ed8a38d87
|
data/CHANGELOG.md
CHANGED
data/ext/isotree/ext.cpp
CHANGED
@@ -2,12 +2,7 @@
|
|
2
2
|
#include <isotree.hpp>
|
3
3
|
|
4
4
|
// rice
|
5
|
-
#include <rice/
|
6
|
-
#include <rice/Hash.hpp>
|
7
|
-
#include <rice/Module.hpp>
|
8
|
-
#include <rice/Object.hpp>
|
9
|
-
#include <rice/String.hpp>
|
10
|
-
#include <rice/Symbol.hpp>
|
5
|
+
#include <rice/rice.hpp>
|
11
6
|
|
12
7
|
using Rice::Array;
|
13
8
|
using Rice::Hash;
|
@@ -18,62 +13,89 @@ using Rice::Symbol;
|
|
18
13
|
using Rice::define_class_under;
|
19
14
|
using Rice::define_module;
|
20
15
|
|
21
|
-
|
22
|
-
NewCategAction from_ruby<NewCategAction>(Object x)
|
16
|
+
namespace Rice::detail
|
23
17
|
{
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
18
|
+
template<>
|
19
|
+
class From_Ruby<NewCategAction>
|
20
|
+
{
|
21
|
+
public:
|
22
|
+
NewCategAction convert(VALUE x)
|
23
|
+
{
|
24
|
+
auto value = Object(x).to_s().str();
|
25
|
+
if (value == "weighted") return Weighted;
|
26
|
+
if (value == "smallest") return Smallest;
|
27
|
+
if (value == "random") return Random;
|
28
|
+
throw std::runtime_error("Unknown new categ action: " + value);
|
29
|
+
}
|
30
|
+
};
|
30
31
|
|
31
|
-
template<>
|
32
|
-
|
33
|
-
{
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
32
|
+
template<>
|
33
|
+
class From_Ruby<MissingAction>
|
34
|
+
{
|
35
|
+
public:
|
36
|
+
MissingAction convert(VALUE x)
|
37
|
+
{
|
38
|
+
auto value = Object(x).to_s().str();
|
39
|
+
if (value == "divide") return Divide;
|
40
|
+
if (value == "impute") return Impute;
|
41
|
+
if (value == "fail") return Fail;
|
42
|
+
throw std::runtime_error("Unknown missing action: " + value);
|
43
|
+
}
|
44
|
+
};
|
40
45
|
|
41
|
-
template<>
|
42
|
-
|
43
|
-
{
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
template<>
|
47
|
+
class From_Ruby<CategSplit>
|
48
|
+
{
|
49
|
+
public:
|
50
|
+
CategSplit convert(VALUE x)
|
51
|
+
{
|
52
|
+
auto value = Object(x).to_s().str();
|
53
|
+
if (value == "subset") return SubSet;
|
54
|
+
if (value == "single_categ") return SingleCateg;
|
55
|
+
throw std::runtime_error("Unknown categ split: " + value);
|
56
|
+
}
|
57
|
+
};
|
49
58
|
|
50
|
-
template<>
|
51
|
-
|
52
|
-
{
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
59
|
+
template<>
|
60
|
+
class From_Ruby<CoefType>
|
61
|
+
{
|
62
|
+
public:
|
63
|
+
CoefType convert(VALUE x)
|
64
|
+
{
|
65
|
+
auto value = Object(x).to_s().str();
|
66
|
+
if (value == "uniform") return Uniform;
|
67
|
+
if (value == "normal") return Normal;
|
68
|
+
throw std::runtime_error("Unknown coef type: " + value);
|
69
|
+
}
|
70
|
+
};
|
58
71
|
|
59
|
-
template<>
|
60
|
-
|
61
|
-
{
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
72
|
+
template<>
|
73
|
+
class From_Ruby<UseDepthImp>
|
74
|
+
{
|
75
|
+
public:
|
76
|
+
UseDepthImp convert(VALUE x)
|
77
|
+
{
|
78
|
+
auto value = Object(x).to_s().str();
|
79
|
+
if (value == "lower") return Lower;
|
80
|
+
if (value == "higher") return Higher;
|
81
|
+
if (value == "same") return Same;
|
82
|
+
throw std::runtime_error("Unknown depth imp: " + value);
|
83
|
+
}
|
84
|
+
};
|
68
85
|
|
69
|
-
template<>
|
70
|
-
|
71
|
-
{
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
86
|
+
template<>
|
87
|
+
class From_Ruby<WeighImpRows>
|
88
|
+
{
|
89
|
+
public:
|
90
|
+
WeighImpRows convert(VALUE x)
|
91
|
+
{
|
92
|
+
auto value = Object(x).to_s().str();
|
93
|
+
if (value == "inverse") return Inverse;
|
94
|
+
if (value == "prop") return Prop;
|
95
|
+
if (value == "flat") return Flat;
|
96
|
+
throw std::runtime_error("Unknown weight imp rows: " + value);
|
97
|
+
}
|
98
|
+
};
|
77
99
|
}
|
78
100
|
|
79
101
|
extern "C"
|
@@ -85,9 +107,9 @@ void Init_ext()
|
|
85
107
|
define_class_under<ExtIsoForest>(rb_mExt, "ExtIsoForest");
|
86
108
|
|
87
109
|
rb_mExt
|
88
|
-
.
|
110
|
+
.define_singleton_function(
|
89
111
|
"fit_iforest",
|
90
|
-
|
112
|
+
[](Hash options) {
|
91
113
|
// model
|
92
114
|
ExtIsoForest iso;
|
93
115
|
|
@@ -204,9 +226,9 @@ void Init_ext()
|
|
204
226
|
|
205
227
|
return iso;
|
206
228
|
})
|
207
|
-
.
|
229
|
+
.define_singleton_function(
|
208
230
|
"predict_iforest",
|
209
|
-
|
231
|
+
[](ExtIsoForest& iso, Hash options) {
|
210
232
|
// data
|
211
233
|
size_t nrows = options.get<size_t, Symbol>("nrows");
|
212
234
|
size_t ncols_numeric = options.get<size_t, Symbol>("ncols_numeric");
|
@@ -260,9 +282,9 @@ void Init_ext()
|
|
260
282
|
}
|
261
283
|
return ret;
|
262
284
|
})
|
263
|
-
.
|
285
|
+
.define_singleton_function(
|
264
286
|
"serialize_ext_isoforest",
|
265
|
-
|
287
|
+
[](ExtIsoForest& iso, String path) {
|
266
288
|
#ifdef _MSC_VER
|
267
289
|
// TODO convert to wchar_t
|
268
290
|
throw std::runtime_error("Not supported on Windows yet");
|
@@ -270,9 +292,9 @@ void Init_ext()
|
|
270
292
|
serialize_ext_isoforest(iso, path.c_str());
|
271
293
|
#endif
|
272
294
|
})
|
273
|
-
.
|
295
|
+
.define_singleton_function(
|
274
296
|
"deserialize_ext_isoforest",
|
275
|
-
|
297
|
+
[](String path) {
|
276
298
|
ExtIsoForest iso;
|
277
299
|
|
278
300
|
#ifdef _MSC_VER
|
data/ext/isotree/extconf.rb
CHANGED
data/lib/isotree/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isotree
|
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: 2021-
|
11
|
+
date: 2021-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rice
|
@@ -16,14 +16,14 @@ 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
28
|
email: andrew@ankane.org
|
29
29
|
executables: []
|
@@ -161,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
161
161
|
requirements:
|
162
162
|
- - ">="
|
163
163
|
- !ruby/object:Gem::Version
|
164
|
-
version: '2.
|
164
|
+
version: '2.6'
|
165
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
166
|
requirements:
|
167
167
|
- - ">="
|