rcf 0.1.0 → 0.1.2

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: ce25c6d66fda9444291e34c20c8dabe8b5f8e295de0b75f70df321a09fbc1595
4
- data.tar.gz: 8fbaf6473cac28f7a8964a4a4227c1985cbc30b0d2218c36c103bacf0a76f04b
3
+ metadata.gz: 0e11d09b695d7375b6f4fce20cf7c3ae8b4cd1128cf1c300ff8ca04ec4bc27ee
4
+ data.tar.gz: 9a4a77df514bbd59e1ab46ac57ff7825a4ecdd9d1aa6d8a6263f4f795f41e7f5
5
5
  SHA512:
6
- metadata.gz: d5e51aeb29db362da886a3159f52e7b8631576993fbd2f4414967f5744c647d5ec31e6a34006032a163b013c858967cf78c7e3dd4a8a895fc2b1dea9738169c9
7
- data.tar.gz: a7c0d71a5742bf574e3ea2995507c0f18a2f4caf2463ac5d4a86506073fb56aeb6c5386d47cfb3f0f87bd9ef1339bad238d3b303a8f26ad249ba9517c183d09c
6
+ metadata.gz: ec0bb36fdd7d87921493375a92b05700417e3edfb01fbcd0df95b5defa99e950f9665f20fcf794f876b4316823f614245db8b313e69bfc1723a6e9ea0d33a0f0
7
+ data.tar.gz: f94c22e51d74cc64d7701f5fe4804a0d9a667eb992bfe761bd4f64202528aa2f7c104a8b62218b0cf3117d33ead6aa13500deb3eb97c2922ba9746ba70eaece6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
- ## 0.1.0 (unreleased)
1
+ ## 0.1.2 (2023-06-07)
2
+
3
+ - Fixed error with `dup` and `clone`
4
+
5
+ ## 0.1.1 (2022-11-06)
6
+
7
+ - Added support for parameters
8
+
9
+ ## 0.1.0 (2022-11-02)
2
10
 
3
11
  - First release
data/NOTICE.txt ADDED
@@ -0,0 +1,2 @@
1
+ RandomCutForest
2
+ Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
data/README.md CHANGED
@@ -51,6 +51,25 @@ forest = Rcf::Forest.new(3)
51
51
  end
52
52
  ```
53
53
 
54
+ ## Parameters
55
+
56
+ Set parameters
57
+
58
+ ```ruby
59
+ Rcf::Forest.new(
60
+ dimensions,
61
+ shingle_size: 1, # shingle size to use
62
+ sample_size: 256, # points to keep in sample for each tree
63
+ number_of_trees: 100, # number of trees to use in the forest
64
+ random_seed: 42, # random seed to use
65
+ parallel: false # enable parallel execution
66
+ )
67
+ ```
68
+
69
+ ## References
70
+
71
+ - [Robust Random Cut Forest Based Anomaly Detection On Streams](https://proceedings.mlr.press/v48/guha16.pdf)
72
+
54
73
  ## History
55
74
 
56
75
  View the [changelog](CHANGELOG.md)
data/lib/rcf/ffi.rb CHANGED
@@ -11,6 +11,7 @@ module Rcf
11
11
  end
12
12
 
13
13
  extern "rcf_forest *rcf_create(size_t dimensions)"
14
+ extern "int rcf_set_param(rcf_forest *forest, const char *param, const char *value)"
14
15
  extern "void rcf_update(rcf_forest *rcf, const float *point)"
15
16
  extern "double rcf_score(rcf_forest *rcf, const float *point)"
16
17
  extern "void rcf_free(rcf_forest *rcf)"
data/lib/rcf/forest.rb CHANGED
@@ -1,10 +1,16 @@
1
1
  module Rcf
2
2
  class Forest
3
- def initialize(dimensions)
3
+ def initialize(dimensions, shingle_size: 1, sample_size: 256, number_of_trees: 100, random_seed: 42, parallel: false)
4
4
  @dimensions = dimensions
5
+
5
6
  @pointer = FFI.rcf_create(dimensions)
7
+ @pointer.free = FFI["rcf_free"]
6
8
 
7
- ObjectSpace.define_finalizer(self, self.class.finalize(@pointer))
9
+ set_param("shingle_size", shingle_size)
10
+ set_param("sample_size", sample_size)
11
+ set_param("number_of_trees", number_of_trees)
12
+ set_param("random_seed", random_seed)
13
+ set_param("parallel", parallel)
8
14
  end
9
15
 
10
16
  def score(point)
@@ -15,13 +21,14 @@ module Rcf
15
21
  FFI.rcf_update(@pointer, point_ptr(point))
16
22
  end
17
23
 
18
- def self.finalize(pointer)
19
- # must use proc instead of stabby lambda
20
- proc { FFI.rcf_free(pointer) }
21
- end
22
-
23
24
  private
24
25
 
26
+ def set_param(param, value)
27
+ if FFI.rcf_set_param(@pointer, param, value.to_s) != 0
28
+ raise ArgumentError, "Invalid value for #{param}"
29
+ end
30
+ end
31
+
25
32
  def point_ptr(point)
26
33
  if point.size != @dimensions
27
34
  raise ArgumentError, "Bad size"
data/lib/rcf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rcf
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -0,0 +1,2 @@
1
+ RandomCutForest
2
+ Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -2,15 +2,17 @@
2
2
 
3
3
  [Random Cut Forest](https://github.com/aws/random-cut-forest-by-aws) (RCF) anomaly detection for C/C++
4
4
 
5
+ :evergreen_tree: Also available for [Ruby](https://github.com/ankane/random-cut-forest-ruby) and [PHP](https://github.com/ankane/random-cut-forest-php), and as a [CLI](https://github.com/ankane/rcf-cli)
6
+
5
7
  [![Build Status](https://github.com/ankane/librcf/workflows/build/badge.svg?branch=master)](https://github.com/ankane/librcf/actions)
6
8
 
7
9
  ## Installation
8
10
 
9
11
  Download the latest version:
10
12
 
11
- - Linux - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-x86_64-unknown-linux-gnu.tar.gz) or [arm64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-aarch64-unknown-linux-gnu.tar.gz)
12
- - Mac - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-x86_64-apple-darwin.tar.gz) or [arm64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-aarch64-apple-darwin.tar.gz)
13
- - Windows - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-x86_64-pc-windows-msvc.zip)
13
+ - Linux - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-x86_64-unknown-linux-gnu.tar.gz) or [arm64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-aarch64-unknown-linux-gnu.tar.gz)
14
+ - Mac - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-x86_64-apple-darwin.tar.gz) or [arm64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-aarch64-apple-darwin.tar.gz)
15
+ - Windows - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-x86_64-pc-windows-msvc.zip)
14
16
 
15
17
  You can also install it with Homebrew:
16
18
 
@@ -32,6 +34,12 @@ Create a forest with 3 dimensions
32
34
  rcf_forest *forest = rcf_create(3);
33
35
  ```
34
36
 
37
+ Set parameters
38
+
39
+ ```c
40
+ rcf_set_param(forest, "number_of_trees", "100");
41
+ ```
42
+
35
43
  Score a point
36
44
 
37
45
  ```c
@@ -65,6 +73,7 @@ float randf() {
65
73
 
66
74
  int main() {
67
75
  rcf_forest *forest = rcf_create(3);
76
+ rcf_set_param(forest, "number_of_trees", "100");
68
77
 
69
78
  for (int i = 0; i < 200; i++) {
70
79
  float point[] = {randf(), randf(), randf()};
@@ -84,6 +93,28 @@ int main() {
84
93
  }
85
94
  ```
86
95
 
96
+ ## Parameters
97
+
98
+ Name | Description | Default Value
99
+ --- | --- | ---
100
+ `shingle_size` | Shingle size to use | 1
101
+ `sample_size` | Points to keep in sample for each tree | 256
102
+ `number_of_trees` | Number of trees to use in the forest | 100
103
+ `random_seed` | Random seed to use | 42
104
+ `parallel` | Enable parallel execution | false
105
+
106
+ Parameter values should always be passed as strings.
107
+
108
+ ```c
109
+ rcf_set_param(forest, "parallel", "true");
110
+ ```
111
+
112
+ `rcf_set_param` returns zero if successful and nonzero if the name or value is invalid or if it’s called after `rcf_score` or `rcf_update`.
113
+
114
+ ## Reference
115
+
116
+ - [Robust Random Cut Forest Based Anomaly Detection On Streams](https://proceedings.mlr.press/v48/guha16.pdf)
117
+
87
118
  ## History
88
119
 
89
120
  View the [changelog](CHANGELOG.md)
Binary file
@@ -0,0 +1,2 @@
1
+ RandomCutForest
2
+ Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -2,15 +2,17 @@
2
2
 
3
3
  [Random Cut Forest](https://github.com/aws/random-cut-forest-by-aws) (RCF) anomaly detection for C/C++
4
4
 
5
+ :evergreen_tree: Also available for [Ruby](https://github.com/ankane/random-cut-forest-ruby) and [PHP](https://github.com/ankane/random-cut-forest-php), and as a [CLI](https://github.com/ankane/rcf-cli)
6
+
5
7
  [![Build Status](https://github.com/ankane/librcf/workflows/build/badge.svg?branch=master)](https://github.com/ankane/librcf/actions)
6
8
 
7
9
  ## Installation
8
10
 
9
11
  Download the latest version:
10
12
 
11
- - Linux - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-x86_64-unknown-linux-gnu.tar.gz) or [arm64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-aarch64-unknown-linux-gnu.tar.gz)
12
- - Mac - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-x86_64-apple-darwin.tar.gz) or [arm64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-aarch64-apple-darwin.tar.gz)
13
- - Windows - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-x86_64-pc-windows-msvc.zip)
13
+ - Linux - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-x86_64-unknown-linux-gnu.tar.gz) or [arm64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-aarch64-unknown-linux-gnu.tar.gz)
14
+ - Mac - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-x86_64-apple-darwin.tar.gz) or [arm64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-aarch64-apple-darwin.tar.gz)
15
+ - Windows - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-x86_64-pc-windows-msvc.zip)
14
16
 
15
17
  You can also install it with Homebrew:
16
18
 
@@ -32,6 +34,12 @@ Create a forest with 3 dimensions
32
34
  rcf_forest *forest = rcf_create(3);
33
35
  ```
34
36
 
37
+ Set parameters
38
+
39
+ ```c
40
+ rcf_set_param(forest, "number_of_trees", "100");
41
+ ```
42
+
35
43
  Score a point
36
44
 
37
45
  ```c
@@ -65,6 +73,7 @@ float randf() {
65
73
 
66
74
  int main() {
67
75
  rcf_forest *forest = rcf_create(3);
76
+ rcf_set_param(forest, "number_of_trees", "100");
68
77
 
69
78
  for (int i = 0; i < 200; i++) {
70
79
  float point[] = {randf(), randf(), randf()};
@@ -84,6 +93,28 @@ int main() {
84
93
  }
85
94
  ```
86
95
 
96
+ ## Parameters
97
+
98
+ Name | Description | Default Value
99
+ --- | --- | ---
100
+ `shingle_size` | Shingle size to use | 1
101
+ `sample_size` | Points to keep in sample for each tree | 256
102
+ `number_of_trees` | Number of trees to use in the forest | 100
103
+ `random_seed` | Random seed to use | 42
104
+ `parallel` | Enable parallel execution | false
105
+
106
+ Parameter values should always be passed as strings.
107
+
108
+ ```c
109
+ rcf_set_param(forest, "parallel", "true");
110
+ ```
111
+
112
+ `rcf_set_param` returns zero if successful and nonzero if the name or value is invalid or if it’s called after `rcf_score` or `rcf_update`.
113
+
114
+ ## Reference
115
+
116
+ - [Robust Random Cut Forest Based Anomaly Detection On Streams](https://proceedings.mlr.press/v48/guha16.pdf)
117
+
87
118
  ## History
88
119
 
89
120
  View the [changelog](CHANGELOG.md)
Binary file
@@ -0,0 +1,2 @@
1
+ RandomCutForest
2
+ Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -2,15 +2,17 @@
2
2
 
3
3
  [Random Cut Forest](https://github.com/aws/random-cut-forest-by-aws) (RCF) anomaly detection for C/C++
4
4
 
5
+ :evergreen_tree: Also available for [Ruby](https://github.com/ankane/random-cut-forest-ruby) and [PHP](https://github.com/ankane/random-cut-forest-php), and as a [CLI](https://github.com/ankane/rcf-cli)
6
+
5
7
  [![Build Status](https://github.com/ankane/librcf/workflows/build/badge.svg?branch=master)](https://github.com/ankane/librcf/actions)
6
8
 
7
9
  ## Installation
8
10
 
9
11
  Download the latest version:
10
12
 
11
- - Linux - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-x86_64-unknown-linux-gnu.tar.gz) or [arm64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-aarch64-unknown-linux-gnu.tar.gz)
12
- - Mac - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-x86_64-apple-darwin.tar.gz) or [arm64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-aarch64-apple-darwin.tar.gz)
13
- - Windows - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-x86_64-pc-windows-msvc.zip)
13
+ - Linux - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-x86_64-unknown-linux-gnu.tar.gz) or [arm64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-aarch64-unknown-linux-gnu.tar.gz)
14
+ - Mac - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-x86_64-apple-darwin.tar.gz) or [arm64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-aarch64-apple-darwin.tar.gz)
15
+ - Windows - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-x86_64-pc-windows-msvc.zip)
14
16
 
15
17
  You can also install it with Homebrew:
16
18
 
@@ -32,6 +34,12 @@ Create a forest with 3 dimensions
32
34
  rcf_forest *forest = rcf_create(3);
33
35
  ```
34
36
 
37
+ Set parameters
38
+
39
+ ```c
40
+ rcf_set_param(forest, "number_of_trees", "100");
41
+ ```
42
+
35
43
  Score a point
36
44
 
37
45
  ```c
@@ -65,6 +73,7 @@ float randf() {
65
73
 
66
74
  int main() {
67
75
  rcf_forest *forest = rcf_create(3);
76
+ rcf_set_param(forest, "number_of_trees", "100");
68
77
 
69
78
  for (int i = 0; i < 200; i++) {
70
79
  float point[] = {randf(), randf(), randf()};
@@ -84,6 +93,28 @@ int main() {
84
93
  }
85
94
  ```
86
95
 
96
+ ## Parameters
97
+
98
+ Name | Description | Default Value
99
+ --- | --- | ---
100
+ `shingle_size` | Shingle size to use | 1
101
+ `sample_size` | Points to keep in sample for each tree | 256
102
+ `number_of_trees` | Number of trees to use in the forest | 100
103
+ `random_seed` | Random seed to use | 42
104
+ `parallel` | Enable parallel execution | false
105
+
106
+ Parameter values should always be passed as strings.
107
+
108
+ ```c
109
+ rcf_set_param(forest, "parallel", "true");
110
+ ```
111
+
112
+ `rcf_set_param` returns zero if successful and nonzero if the name or value is invalid or if it’s called after `rcf_score` or `rcf_update`.
113
+
114
+ ## References
115
+
116
+ - [Robust Random Cut Forest Based Anomaly Detection On Streams](https://proceedings.mlr.press/v48/guha16.pdf)
117
+
87
118
  ## History
88
119
 
89
120
  View the [changelog](CHANGELOG.md)
Binary file
@@ -0,0 +1,2 @@
1
+ RandomCutForest
2
+ Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -2,15 +2,17 @@
2
2
 
3
3
  [Random Cut Forest](https://github.com/aws/random-cut-forest-by-aws) (RCF) anomaly detection for C/C++
4
4
 
5
+ :evergreen_tree: Also available for [Ruby](https://github.com/ankane/random-cut-forest-ruby) and [PHP](https://github.com/ankane/random-cut-forest-php), and as a [CLI](https://github.com/ankane/rcf-cli)
6
+
5
7
  [![Build Status](https://github.com/ankane/librcf/workflows/build/badge.svg?branch=master)](https://github.com/ankane/librcf/actions)
6
8
 
7
9
  ## Installation
8
10
 
9
11
  Download the latest version:
10
12
 
11
- - Linux - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-x86_64-unknown-linux-gnu.tar.gz) or [arm64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-aarch64-unknown-linux-gnu.tar.gz)
12
- - Mac - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-x86_64-apple-darwin.tar.gz) or [arm64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-aarch64-apple-darwin.tar.gz)
13
- - Windows - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.0/librcf-0.1.0-x86_64-pc-windows-msvc.zip)
13
+ - Linux - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-x86_64-unknown-linux-gnu.tar.gz) or [arm64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-aarch64-unknown-linux-gnu.tar.gz)
14
+ - Mac - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-x86_64-apple-darwin.tar.gz) or [arm64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-aarch64-apple-darwin.tar.gz)
15
+ - Windows - [x86_64](https://github.com/ankane/librcf/releases/download/v0.1.1/librcf-0.1.1-x86_64-pc-windows-msvc.zip)
14
16
 
15
17
  You can also install it with Homebrew:
16
18
 
@@ -32,6 +34,12 @@ Create a forest with 3 dimensions
32
34
  rcf_forest *forest = rcf_create(3);
33
35
  ```
34
36
 
37
+ Set parameters
38
+
39
+ ```c
40
+ rcf_set_param(forest, "number_of_trees", "100");
41
+ ```
42
+
35
43
  Score a point
36
44
 
37
45
  ```c
@@ -65,6 +73,7 @@ float randf() {
65
73
 
66
74
  int main() {
67
75
  rcf_forest *forest = rcf_create(3);
76
+ rcf_set_param(forest, "number_of_trees", "100");
68
77
 
69
78
  for (int i = 0; i < 200; i++) {
70
79
  float point[] = {randf(), randf(), randf()};
@@ -84,6 +93,28 @@ int main() {
84
93
  }
85
94
  ```
86
95
 
96
+ ## Parameters
97
+
98
+ Name | Description | Default Value
99
+ --- | --- | ---
100
+ `shingle_size` | Shingle size to use | 1
101
+ `sample_size` | Points to keep in sample for each tree | 256
102
+ `number_of_trees` | Number of trees to use in the forest | 100
103
+ `random_seed` | Random seed to use | 42
104
+ `parallel` | Enable parallel execution | false
105
+
106
+ Parameter values should always be passed as strings.
107
+
108
+ ```c
109
+ rcf_set_param(forest, "parallel", "true");
110
+ ```
111
+
112
+ `rcf_set_param` returns zero if successful and nonzero if the name or value is invalid or if it’s called after `rcf_score` or `rcf_update`.
113
+
114
+ ## Reference
115
+
116
+ - [Robust Random Cut Forest Based Anomaly Detection On Streams](https://proceedings.mlr.press/v48/guha16.pdf)
117
+
87
118
  ## History
88
119
 
89
120
  View the [changelog](CHANGELOG.md)
Binary file