Random Cut Forest anomaly detection for C/C++

Overview

Random Cut Forest C/C++

Random Cut Forest (RCF) anomaly detection for C/C++

🌲 Also available for Ruby and PHP, and as a CLI

Build Status

Installation

Download the latest version:

You can also install it with Homebrew:

brew install ankane/brew/librcf

Getting Started

Include the header

#include "rcf.h"

Create a forest with 3 dimensions

rcf_forest *forest = rcf_create(3);

Set parameters

rcf_set_param(forest, "number_of_trees", "100");

Score a point

float point[] = {1.0, 2.0, 3.0};
double score = rcf_score(forest, point);

Update with a point

rcf_update(forest, point);

Free the forest

rcf_free(forest);

Example

#include <stdio.h>
#include <stdlib.h>

#include "rcf.h"

float randf() {
    return rand() / (float) RAND_MAX;
}

int main() {
    rcf_forest *forest = rcf_create(3);
    rcf_set_param(forest, "number_of_trees", "100");

    for (int i = 0; i < 200; i++) {
        float point[] = {randf(), randf(), randf()};

        // make the second to last point an anomaly
        if (i == 198) {
            point[1] = 2;
        }

        double score = rcf_score(forest, point);
        printf("point = %d, score = %f\n", i, score);
        rcf_update(forest, point);
    }

    rcf_free(forest);
    return 0;
}

Parameters

Name Description Default Value
shingle_size Shingle size to use 1
sample_size Points to keep in sample for each tree 256
number_of_trees Number of trees to use in the forest 100
random_seed Random seed to use 42
parallel Enable parallel execution false

Parameter values should always be passed as strings.

rcf_set_param(forest, "sample_size", "256");
rcf_set_param(forest, "parallel", "true");

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.

References

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

To get started with development:

git clone https://github.com/ankane/librcf.git
cd librcf
cargo build
cargo test

To generate headers:

cbindgen > include/rcf.h
You might also like...
Dark Forest, the world's first decentralized real-time strategy game.

darkforest-rs Dark Forest, the world's first decentralized real-time strategy game.

Terminal UI implementation and types for the Dark Forest game

dark-forest.rs Terminal UI implementation and types for the Dark Forest game Development We use the standard Rust toolchain cargo check

Rust implementation of Adobe's stlab::forest data structure

skog Swedish for "forest". A pure rust implementation of Adobe's stlab::forest data structure. Introduction A "forest" is a tree-like data structure.

Forest is an implementation of Filecoin written in Rust.
Forest is an implementation of Filecoin written in Rust.

Forest is an implementation of Filecoin written in Rust. The implementation will take a modular approach to building a full Filecoin node in Rust from the Filecoin Protocol Specification, specifically the virtual machine, blockchain, and node system.

Using bevy and custom render pipelines in order to render many objects in a forest using chunks for performance.

bevy_efficient_forest_example Using bevy and custom render pipelines in order to render many objects in a forest using chunks for performance. Grass i

Natural language detection library for Rust. Try demo online: https://www.greyblake.com/whatlang/
Natural language detection library for Rust. Try demo online: https://www.greyblake.com/whatlang/

Whatlang Natural language detection for Rust with focus on simplicity and performance. Content Features Get started Documentation Supported languages

Super Fast Sub-domain Takeover Detection!
Super Fast Sub-domain Takeover Detection!

NtHiM - Super Fast Sub-domain Takeover Detection Installation Method 1: Using Pre-compiled Binaries The pre-compiled binaries for different systems ar

👄 The most accurate natural language detection library in the Rust ecosystem, suitable for long and short text alike
👄 The most accurate natural language detection library in the Rust ecosystem, suitable for long and short text alike

Table of Contents What does this library do? Why does this library exist? Which languages are supported? How good is it? Why is it better than other l

Semantic text segmentation. For sentence boundary detection, compound splitting and more.

NNSplit A tool to split text using a neural network. The main application is sentence boundary detection, but e. g. compound splitting for German is a

Face detection library for the Rust programming language
Face detection library for the Rust programming language

Rustface SeetaFace detection library for the Rust programming language Example of demo program output SEETAFACE C++ – Github repository for the origin

Super lightweight and dead-simple CI detection.

This crate tells you if you're in a CI environment or not. It does not tell you which you're in, but it makes a good effort to make sure to accurately

lingua-rs Python binding. An accurate natural language detection library, suitable for long and short text alike.

lingua-py lingua-rs Python binding. An accurate natural language detection library, suitable for long and short text alike. Installation pip install l

Rust Memory Safety & Undefined Behavior Detection

Rudra is a static analyzer to detect common undefined behaviors in Rust programs. It is capable of analyzing single Rust packages as well as all the packages on crates.io.

Small container runtime for threat detection

confine Containers, but for dynamic malware analysis confine is a container runtime for dynamically analyzing suspicious executables. Given a sample s

2 and 3-dimensional collision detection library in Rust.

2D Documentation | 3D Documentation | User Guide | Forum ⚠️ **This crate is now passively-maintained. It is being superseded by the Parry project.** ⚠

Motion detection & video recording software based on OpenCV, built for research on Bumblebees

BombusCV Motion detection & video recording software based on OpenCV, built for research on Bumblebees (hence the name). Index Use case Examples Insta

Plugins and helpful methods for using sepax2d with Bevy for 2d overlap detection and collision resolution.

bevy_sepax2d Plugins and helpful methods for using sepax2d with Bevy for 2d overlap detection and collision resolution. Compatible Versions bevy bevy_

Now, the Host is Mine! - Super Fast Sub-domain Takeover Detection!
Now, the Host is Mine! - Super Fast Sub-domain Takeover Detection!

NtH1M - Super Fast Sub-domain Takeover Detection Notice This is a sad notice that our Internet Hero (@TheBinitGhimire) had recent demise on 26th of Ju

Pure Rust port of CRFsuite: a fast implementation of Conditional Random Fields (CRFs)

crfs-rs Pure Rust port of CRFsuite: a fast implementation of Conditional Random Fields (CRFs) Currently only support prediction, model training is not

Owner
Andrew Kane
Andrew Kane
A Rust🦀 implementation of CRAFTML, an Efficient Clustering-based Random Forest for Extreme Multi-label Learning

craftml-rs A Rust implementation of CRAFTML, an Efficient Clustering-based Random Forest for Extreme Multi-label Learning (Siblini et al., 2018). Perf

Tom Dong 15 Nov 6, 2022
A random forest implementation in Rust

randomforest A random forest implementation in Rust. Examples use randomforest::criterion::Mse; use randomforest::RandomForestRegressorOptions; use ra

Takeru Ohta 3 Nov 19, 2022
A neural network model that can approximate any non-linear function by using the random search algorithm for the optimization of the loss function.

random_search A neural network model that can approximate any non-linear function by using the random search algorithm for the optimization of the los

ph04 2 Apr 1, 2022
Rust port of the extended isolation forest algorithm for anomaly detection

Extended Isolation Forest This is a rust port of the anomaly detection algorithm described in Extended Isolation Forest and implemented in https://git

Nico Mandery 6 Oct 21, 2022
Time series anomaly detection for Rust

AnomalyDetection.rs Time series AnomalyDetection for Rust Learn how it works Installation Add this line to your application’s Cargo.toml under [depend

Andrew Kane 6 Nov 21, 2022
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
A Rust🦀 implementation of CRAFTML, an Efficient Clustering-based Random Forest for Extreme Multi-label Learning

craftml-rs A Rust implementation of CRAFTML, an Efficient Clustering-based Random Forest for Extreme Multi-label Learning (Siblini et al., 2018). Perf

Tom Dong 15 Nov 6, 2022
A random forest implementation in Rust

randomforest A random forest implementation in Rust. Examples use randomforest::criterion::Mse; use randomforest::RandomForestRegressorOptions; use ra

Takeru Ohta 3 Nov 19, 2022
This is choose, a human-friendly and fast alternative to cut and (sometimes) awk

Choose This is choose, a human-friendly and fast alternative to cut and (sometimes) awk Features terse field selection syntax similar to Python's list

Ryan Geary 1.4k Jan 7, 2023
hck is a shortening of hack, a rougher form of cut.

?? hck A sharp cut(1) clone. hck is a shortening of hack, a rougher form of cut. A close to drop in replacement for cut that can use a regex delimiter

Seth 602 Dec 29, 2022