PHPackages                             ankane/rcf - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ankane/rcf

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ankane/rcf
==========

Random Cut Forest anomaly detection for PHP

v0.2.0(1y ago)23.7k—8.3%2Apache-2.0PHPPHP &gt;= 8.1CI passing

Since Nov 3Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/ankane/random-cut-forest-php)[ Packagist](https://packagist.org/packages/ankane/rcf)[ RSS](/packages/ankane-rcf/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

Random Cut Forest PHP
=====================

[](#random-cut-forest-php)

[Random Cut Forest](https://github.com/aws/random-cut-forest-by-aws) (RCF) anomaly detection for PHP

[![Build Status](https://github.com/ankane/random-cut-forest-php/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/random-cut-forest-php/actions)

Installation
------------

[](#installation)

Run:

```
composer require ankane/rcf
```

Add scripts to `composer.json` to download the shared library:

```
    "scripts": {
        "post-install-cmd": "Rcf\\Vendor::check",
        "post-update-cmd": "Rcf\\Vendor::check"
    }
```

And run:

```
composer install
```

Getting Started
---------------

[](#getting-started)

Create a forest with 3 dimensions

```
$forest = new Rcf\Forest(3);
```

Score a point

```
$forest->score([1.0, 2.0, 3.0]);
```

Update with a point

```
$forest->update([1.0, 2.0, 3.0]);
```

Example
-------

[](#example)

```
$forest = new Rcf\Forest(3);

for ($i = 0; $i < 200; $i++) {
    $point = [];
    $point[0] = mt_rand() / mt_getrandmax();
    $point[1] = mt_rand() / mt_getrandmax();
    $point[2] = mt_rand() / mt_getrandmax();

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

    $score = $forest->score($point);
    echo "point = $i, score = $score\n";
    $forest->update($point);
}
```

Parameters
----------

[](#parameters)

Set parameters

```
new Rcf\Forest(
    $dimensions,
    shingleSize: 1,         // shingle size to use
    sampleSize: 256,        // points to keep in sample for each tree
    numberOfTrees: 100,     // number of trees to use in the forest
    randomSeed: 42,         // random seed to use
    parallel: false         // enable parallel execution
)
```

References
----------

[](#references)

- [Robust Random Cut Forest Based Anomaly Detection On Streams](https://proceedings.mlr.press/v48/guha16.pdf)

History
-------

[](#history)

View the [changelog](CHANGELOG.md)

Contributing
------------

[](#contributing)

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

- [Report bugs](https://github.com/ankane/random-cut-forest-php/issues)
- Fix bugs and [submit pull requests](https://github.com/ankane/random-cut-forest-php/pulls)
- Write, clarify, or fix documentation
- Suggest or add new features

To get started with development:

```
git clone https://github.com/ankane/random-cut-forest-php.git
cd random-cut-forest-php
composer install
composer test
```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance63

Regular maintenance activity

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~240 days

Total

4

Last Release

572d ago

PHP version history (2 changes)v0.1.0PHP &gt;= 8.0

v0.2.0PHP &gt;= 8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/220358?v=4)[Andrew Kane](/maintainers/ankane)[@ankane](https://github.com/ankane)

---

Top Contributors

[![ankane](https://avatars.githubusercontent.com/u/220358?v=4)](https://github.com/ankane "ankane (27 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ankane-rcf/health.svg)

```
[![Health](https://phpackages.com/badges/ankane-rcf/health.svg)](https://phpackages.com/packages/ankane-rcf)
```

###  Alternatives

[tecnocen/yii2-bootstrap-year-calendar

Yii2 widget for bootstrap-year-calendar plugin

1317.7k](/packages/tecnocen-yii2-bootstrap-year-calendar)[rspeekenbrink/laravel-menu

Simple menu generation in Laravel

164.3k](/packages/rspeekenbrink-laravel-menu)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
