cii-text-analysis/vendor/rubix/ml/tests/Specifications/SamplesAreCompatibleWithEstimatorTest.php
Jéremy Munsch f68d2ac333
premier poc
2026-02-11 08:24:04 +01:00

76 lines
1.9 KiB
PHP

<?php
namespace Rubix\ML\Tests\Specifications;
use Rubix\ML\Datasets\Unlabeled;
use Rubix\ML\Classifiers\NaiveBayes;
use Rubix\ML\Regressors\RegressionTree;
use Rubix\ML\Clusterers\GaussianMixture;
use Rubix\ML\Specifications\SamplesAreCompatibleWithEstimator;
use PHPUnit\Framework\TestCase;
use Generator;
/**
* @group Specifications
* @covers \Rubix\ML\Specifications\SamplesAreCompatibleWithEstimator
*/
class SamplesAreCompatibleWithEstimatorTest extends TestCase
{
/**
* @test
* @dataProvider passesProvider
*
* @param \Rubix\ML\Specifications\SamplesAreCompatibleWithEstimator $specification
* @param bool $expected
*/
public function passes(SamplesAreCompatibleWithEstimator $specification, bool $expected) : void
{
$this->assertSame($expected, $specification->passes());
}
/**
* @return \Generator<array>
*/
public function passesProvider() : Generator
{
yield [
SamplesAreCompatibleWithEstimator::with(
Unlabeled::quick([
['swamp', 'island', 'black knight', 'counter spell'],
]),
new NaiveBayes()
),
true,
];
yield [
SamplesAreCompatibleWithEstimator::with(
Unlabeled::quick([
[6.0, -1.1, 5, 'college'],
]),
new RegressionTree()
),
true,
];
yield [
SamplesAreCompatibleWithEstimator::with(
Unlabeled::quick([
[6.0, -1.1, 5, 'college'],
]),
new NaiveBayes()
),
false,
];
yield [
SamplesAreCompatibleWithEstimator::with(
Unlabeled::quick([
[6.0, -1.1, 5, 'college'],
]),
new GaussianMixture(3)
),
false,
];
}
}