Skip to content

Commit 0fa98ce

Browse files
committed
Merge branch '2.5' of https://github.com/RubixML/ML into 2.5
2 parents e3790bd + 277e37b commit 0fa98ce

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
- 2.5.0
22
- Added Vantage Point Spatial tree
33
- Blob Generator can now `simulate()` a Dataset object
4+
- Added Wrapper interface
5+
- Added Swoole Backend
6+
- Plus Plus added check for min number of sample seeds
47

58
- 2.4.1
69
- Sentence Tokenizer fix Arabic and Farsi language support

src/Clusterers/Seeders/PlusPlus.php

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Rubix\ML\Kernels\Distance\Distance;
77
use Rubix\ML\Kernels\Distance\Euclidean;
88
use Rubix\ML\Specifications\DatasetIsNotEmpty;
9+
use Rubix\ML\Exceptions\RuntimeException;
910

1011
use function count;
1112

@@ -49,12 +50,18 @@ public function __construct(?Distance $kernel = null)
4950
*
5051
* @param Dataset $dataset
5152
* @param int $k
53+
* @throws RuntimeException
5254
* @return list<list<string|int|float>>
5355
*/
5456
public function seed(Dataset $dataset, int $k) : array
5557
{
5658
DatasetIsNotEmpty::with($dataset)->check();
5759

60+
if ($k > $dataset->numSamples()) {
61+
throw new RuntimeException("Cannot seed $k clusters with only "
62+
. $dataset->numSamples() . ' samples.');
63+
}
64+
5865
$centroids = $dataset->randomSubset(1)->samples();
5966

6067
while (count($centroids) < $k) {

tests/Transformers/MaxAbsoluteScalerTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ public function fitUpdateTransformReverse() : void
7777

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

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

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

tests/Transformers/RobustStandardizerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function fitUpdateTransformReverse() : void
8686

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

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

9292
/**

0 commit comments

Comments
 (0)