2017-02-07 11:37:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2017-09-02 19:39:59 +00:00
|
|
|
namespace tests\Phpml\Classification\Ensemble;
|
2017-02-07 11:37:56 +00:00
|
|
|
|
|
|
|
use Phpml\Classification\DecisionTree;
|
2017-11-06 07:56:37 +00:00
|
|
|
use Phpml\Classification\Ensemble\RandomForest;
|
2017-02-07 11:37:56 +00:00
|
|
|
use Phpml\Classification\NaiveBayes;
|
|
|
|
|
|
|
|
class RandomForestTest extends BaggingTest
|
|
|
|
{
|
|
|
|
protected function getClassifier($numBaseClassifiers = 50)
|
|
|
|
{
|
|
|
|
$classifier = new RandomForest($numBaseClassifiers);
|
|
|
|
$classifier->setFeatureSubsetRatio('log');
|
2017-08-17 06:50:37 +00:00
|
|
|
|
2017-02-07 11:37:56 +00:00
|
|
|
return $classifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getAvailableBaseClassifiers()
|
|
|
|
{
|
2017-08-17 06:50:37 +00:00
|
|
|
return [DecisionTree::class => ['depth' => 5]];
|
2017-02-07 11:37:56 +00:00
|
|
|
}
|
|
|
|
|
2017-11-14 20:21:23 +00:00
|
|
|
public function testOtherBaseClassifier(): void
|
2017-02-07 11:37:56 +00:00
|
|
|
{
|
|
|
|
try {
|
|
|
|
$classifier = new RandomForest();
|
|
|
|
$classifier->setClassifer(NaiveBayes::class);
|
|
|
|
$this->assertEquals(0, 1);
|
|
|
|
} catch (\Exception $ex) {
|
|
|
|
$this->assertEquals(1, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|