Skip to content

Commit

Permalink
Merge branch '2.5' of https://github.com/RubixML/ML into 2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdalpino committed Feb 15, 2024
2 parents e3790bd + 277e37b commit 0fa98ce
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
- 2.5.0
- Added Vantage Point Spatial tree
- Blob Generator can now `simulate()` a Dataset object
- Added Wrapper interface
- Added Swoole Backend
- Plus Plus added check for min number of sample seeds

- 2.4.1
- Sentence Tokenizer fix Arabic and Farsi language support
Expand Down
7 changes: 7 additions & 0 deletions src/Clusterers/Seeders/PlusPlus.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Rubix\ML\Kernels\Distance\Distance;
use Rubix\ML\Kernels\Distance\Euclidean;
use Rubix\ML\Specifications\DatasetIsNotEmpty;
use Rubix\ML\Exceptions\RuntimeException;

use function count;

Expand Down Expand Up @@ -49,12 +50,18 @@ public function __construct(?Distance $kernel = null)
*
* @param Dataset $dataset
* @param int $k
* @throws RuntimeException
* @return list<list<string|int|float>>
*/
public function seed(Dataset $dataset, int $k) : array
{
DatasetIsNotEmpty::with($dataset)->check();

if ($k > $dataset->numSamples()) {
throw new RuntimeException("Cannot seed $k clusters with only "
. $dataset->numSamples() . ' samples.');
}

$centroids = $dataset->randomSubset(1)->samples();

while (count($centroids) < $k) {
Expand Down
6 changes: 3 additions & 3 deletions tests/Transformers/MaxAbsoluteScalerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public function fitUpdateTransformReverse() : void

$this->assertCount(3, $sample);

$this->assertEqualsWithDelta(0, $sample[0], 1);
$this->assertEqualsWithDelta(0, $sample[1], 1);
$this->assertEqualsWithDelta(0, $sample[2], 1);
$this->assertEqualsWithDelta(0, $sample[0], 1 + 1e-8);
$this->assertEqualsWithDelta(0, $sample[1], 1 + 1e-8);
$this->assertEqualsWithDelta(0, $sample[2], 1 + 1e-8);

$dataset->reverseApply($this->transformer);

Expand Down
2 changes: 1 addition & 1 deletion tests/Transformers/RobustStandardizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function fitUpdateTransformReverse() : void

$dataset->reverseApply($this->transformer);

$this->assertEquals($original, $dataset->sample(0));
$this->assertEqualsWithDelta($original, $dataset->sample(0), 1e-8);
}

/**
Expand Down

0 comments on commit 0fa98ce

Please sign in to comment.