rcf 0.1.0 → 0.1.1

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: ce25c6d66fda9444291e34c20c8dabe8b5f8e295de0b75f70df321a09fbc1595
4
- data.tar.gz: 8fbaf6473cac28f7a8964a4a4227c1985cbc30b0d2218c36c103bacf0a76f04b
3
+ metadata.gz: d050fe5e3a88cc6361c5cdb592b558cca82c1c7c35daeb9398db69929d94451d
4
+ data.tar.gz: 932e1d587efeed620a8f833ab95a2b94a29424430264c11b92cc56e88a86bb3e
5
5
  SHA512:
6
- metadata.gz: d5e51aeb29db362da886a3159f52e7b8631576993fbd2f4414967f5744c647d5ec31e6a34006032a163b013c858967cf78c7e3dd4a8a895fc2b1dea9738169c9
7
- data.tar.gz: a7c0d71a5742bf574e3ea2995507c0f18a2f4caf2463ac5d4a86506073fb56aeb6c5386d47cfb3f0f87bd9ef1339bad238d3b303a8f26ad249ba9517c183d09c
6
+ metadata.gz: dd55dac9c224b53617af4a91d56c4bcfdd0b1317b03bee93c35fba20798d3d94a1af874ae9a103b32cd53f5418c89c4a7489ae3bd3c8cfce0267a8beb3b9837b
7
+ data.tar.gz: 3ab0d7a74cf233855b28dcb751c11e77b78efbd88afcfb19e1cfd6533852f3f354db74e06726883bb9dcd3af27b744a6dfe887ace0f60aaca9848ee2d915e7ec
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
- ## 0.1.0 (unreleased)
1
+ ## 0.1.1 (2022-11-06)
2
+
3
+ - Added support for parameters
4
+
5
+ ## 0.1.0 (2022-11-02)
2
6
 
3
7
  - 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 [unreleased]
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
- @pointer = FFI.rcf_create(dimensions)
6
5
 
6
+ @pointer = FFI.rcf_create(dimensions)
7
7
  ObjectSpace.define_finalizer(self, self.class.finalize(@pointer))
8
+
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)
@@ -22,6 +28,12 @@ module Rcf
22
28
 
23
29
  private
24
30
 
31
+ def set_param(param, value)
32
+ if FFI.rcf_set_param(@pointer, param, value.to_s) != 0
33
+ raise ArgumentError, "Invalid value for #{param}"
34
+ end
35
+ end
36
+
25
37
  def point_ptr(point)
26
38
  if point.size != @dimensions
27
39
  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.1"
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