php-ml/tests/Classification/Ensemble/RandomForestTest.php

38 lines
911 B
PHP
Raw Normal View History

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