1. Go to this page and download the library: Download ankane/rcf library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ankane / rcf example snippets
$forest = new Rcf\Forest(3);
$forest->score([1.0, 2.0, 3.0]);
$forest->update([1.0, 2.0, 3.0]);
$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);
}
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
)
sh
git clone https://github.com/ankane/random-cut-forest-php.git
cd random-cut-forest-php
composer install
composer test
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.