generator = new Agglomerate([ 'red' => new Blob([255, 32, 0], 30.0), 'green' => new Blob([0, 128, 0], 10.0), 'blue' => new Blob([0, 32, 255], 20.0), ], [2, 3, 4]); $this->embedder = new TSNE(1, 10.0, 10, 12.0, 500, 1e-7, 10, new Euclidean()); $this->embedder->setLogger(new BlackHole()); srand(self::RANDOM_SEED); } /** * @test */ public function build() : void { $this->assertInstanceOf(TSNE::class, $this->embedder); $this->assertInstanceOf(Verbose::class, $this->embedder); } /** * @test */ public function badNumDimensions() : void { $this->expectException(InvalidArgumentException::class); new TSNE(0); } /** * @test */ public function compatibility() : void { $expected = [ DataType::continuous(), ]; $this->assertEquals($expected, $this->embedder->compatibility()); } /** * @test */ public function transform() : void { $dataset = $this->generator->generate(self::TEST_SIZE); $dataset->apply($this->embedder); $this->assertCount(self::TEST_SIZE, $dataset); $this->assertCount(1, $dataset->sample(0)); $losses = $this->embedder->losses(); $this->assertIsArray($losses); $this->assertContainsOnly('float', $losses); } }