rcf 0.1.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 +7 -0
- data/CHANGELOG.md +3 -0
- data/LICENSE.txt +202 -0
- data/README.md +75 -0
- data/lib/rcf/ffi.rb +18 -0
- data/lib/rcf/forest.rb +32 -0
- data/lib/rcf/version.rb +3 -0
- data/lib/rcf.rb +35 -0
- data/vendor/aarch64-linux/LICENSE +202 -0
- data/vendor/aarch64-linux/README.md +113 -0
- data/vendor/aarch64-linux/THIRD-PARTY-LICENSES +7025 -0
- data/vendor/aarch64-linux/lib/librcf.so +0 -0
- data/vendor/arm64-darwin/LICENSE +202 -0
- data/vendor/arm64-darwin/README.md +113 -0
- data/vendor/arm64-darwin/THIRD-PARTY-LICENSES +7025 -0
- data/vendor/arm64-darwin/lib/librcf.dylib +0 -0
- data/vendor/x64-mingw/LICENSE +202 -0
- data/vendor/x64-mingw/README.md +113 -0
- data/vendor/x64-mingw/THIRD-PARTY-LICENSES +7025 -0
- data/vendor/x64-mingw/lib/rcf.dll +0 -0
- data/vendor/x86_64-darwin/LICENSE +202 -0
- data/vendor/x86_64-darwin/README.md +113 -0
- data/vendor/x86_64-darwin/THIRD-PARTY-LICENSES +7025 -0
- data/vendor/x86_64-darwin/lib/librcf.dylib +0 -0
- data/vendor/x86_64-linux/LICENSE +202 -0
- data/vendor/x86_64-linux/README.md +113 -0
- data/vendor/x86_64-linux/THIRD-PARTY-LICENSES +7025 -0
- data/vendor/x86_64-linux/lib/librcf.so +0 -0
- metadata +69 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Random Cut Forest C/C++
|
|
2
|
+
|
|
3
|
+
[Random Cut Forest](https://github.com/aws/random-cut-forest-by-aws) (RCF) anomaly detection for C/C++
|
|
4
|
+
|
|
5
|
+
[](https://github.com/ankane/librcf/actions)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Download the latest version:
|
|
10
|
+
|
|
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)
|
|
14
|
+
|
|
15
|
+
You can also install it with Homebrew:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
brew install ankane/brew/librcf
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Getting Started
|
|
22
|
+
|
|
23
|
+
Include the header
|
|
24
|
+
|
|
25
|
+
```c
|
|
26
|
+
#include "rcf.h"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Create a forest with 3 dimensions
|
|
30
|
+
|
|
31
|
+
```c
|
|
32
|
+
rcf_forest *forest = rcf_create(3);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Score a point
|
|
36
|
+
|
|
37
|
+
```c
|
|
38
|
+
float point[] = {1.0, 2.0, 3.0};
|
|
39
|
+
double score = rcf_score(forest, point);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Update with a point
|
|
43
|
+
|
|
44
|
+
```c
|
|
45
|
+
rcf_update(forest, point);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Free the forest
|
|
49
|
+
|
|
50
|
+
```c
|
|
51
|
+
rcf_free(forest);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Example
|
|
55
|
+
|
|
56
|
+
```c
|
|
57
|
+
#include <stdio.h>
|
|
58
|
+
#include <stdlib.h>
|
|
59
|
+
|
|
60
|
+
#include "rcf.h"
|
|
61
|
+
|
|
62
|
+
float randf() {
|
|
63
|
+
return rand() / (float) RAND_MAX;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
int main() {
|
|
67
|
+
rcf_forest *forest = rcf_create(3);
|
|
68
|
+
|
|
69
|
+
for (int i = 0; i < 200; i++) {
|
|
70
|
+
float point[] = {randf(), randf(), randf()};
|
|
71
|
+
|
|
72
|
+
// make the second to last point an anomaly
|
|
73
|
+
if (i == 198) {
|
|
74
|
+
point[1] = 2;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
double score = rcf_score(forest, point);
|
|
78
|
+
printf("point = %d, score = %f\n", i, score);
|
|
79
|
+
rcf_update(forest, point);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
rcf_free(forest);
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## History
|
|
88
|
+
|
|
89
|
+
View the [changelog](CHANGELOG.md)
|
|
90
|
+
|
|
91
|
+
## Contributing
|
|
92
|
+
|
|
93
|
+
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
|
94
|
+
|
|
95
|
+
- [Report bugs](https://github.com/ankane/librcf/issues)
|
|
96
|
+
- Fix bugs and [submit pull requests](https://github.com/ankane/librcf/pulls)
|
|
97
|
+
- Write, clarify, or fix documentation
|
|
98
|
+
- Suggest or add new features
|
|
99
|
+
|
|
100
|
+
To get started with development:
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
git clone https://github.com/ankane/librcf.git
|
|
104
|
+
cd librcf
|
|
105
|
+
cargo build
|
|
106
|
+
cargo test
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
To generate headers:
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
cbindgen > include/rcf.h
|
|
113
|
+
```
|