mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2025-01-10 09:02:15 +00:00
1d73503958
* Fuzzy C-Means implementation * Update FuzzyCMeans * Rename FuzzyCMeans to FuzzyCMeans.php * Update NaiveBayes.php * Small fix applied to improve training performance array_unique is replaced with array_count_values+array_keys which is way faster * Revert "Small fix applied to improve training performance" This reverts commit c20253f16ac3e8c37d33ecaee28a87cc767e3b7f. * Revert "Revert "Small fix applied to improve training performance"" This reverts commit ea10e136c4c11b71609ccdcaf9999067e4be473e. * Revert "Small fix applied to improve training performance" This reverts commit c20253f16ac3e8c37d33ecaee28a87cc767e3b7f. * First DecisionTree implementation * Revert "First DecisionTree implementation" This reverts commit 4057a08679c26010c39040a48a3e6dad994a1a99. * DecisionTree * FCM Test * FCM Test * DecisionTree Test * Ensemble classifiers: Bagging and RandomForests * test * Fixes for conflicted files * Bagging and RandomForest ensemble algorithms * Changed unit test * Changed unit test * Changed unit test * Bagging and RandomForest ensemble algorithms * Baggging and RandomForest ensemble algorithms * Bagging and RandomForest ensemble algorithms RandomForest algorithm is improved with changes to original DecisionTree * Bagging and RandomForest ensemble algorithms * Slight fix about use of global Exception class * Fixed the error about wrong use of global Exception class * RandomForest code formatting
39 lines
1001 B
PHP
39 lines
1001 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace tests\Classification\Ensemble;
|
|
|
|
use Phpml\Classification\Ensemble\RandomForest;
|
|
use Phpml\Classification\DecisionTree;
|
|
use Phpml\Classification\NaiveBayes;
|
|
use Phpml\Classification\KNearestNeighbors;
|
|
use Phpml\ModelManager;
|
|
use tests\Classification\Ensemble\BaggingTest;
|
|
|
|
class RandomForestTest extends BaggingTest
|
|
{
|
|
protected function getClassifier($numBaseClassifiers = 50)
|
|
{
|
|
$classifier = new RandomForest($numBaseClassifiers);
|
|
$classifier->setFeatureSubsetRatio('log');
|
|
return $classifier;
|
|
}
|
|
|
|
protected function getAvailableBaseClassifiers()
|
|
{
|
|
return [ DecisionTree::class => ['depth' => 5] ];
|
|
}
|
|
|
|
public function testOtherBaseClassifier()
|
|
{
|
|
try {
|
|
$classifier = new RandomForest();
|
|
$classifier->setClassifer(NaiveBayes::class);
|
|
$this->assertEquals(0, 1);
|
|
} catch (\Exception $ex) {
|
|
$this->assertEquals(1, 1);
|
|
}
|
|
}
|
|
}
|