Skip to content

Commit 4033a9d

Browse files
committed
Merge branch '2.5' into 3.0
2 parents dd56e81 + 8e299a2 commit 4033a9d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+159
-130
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"@test",
8181
"@check"
8282
],
83-
"analyze": "phpstan analyse -c phpstan.neon",
83+
"analyze": "phpstan analyse -c phpstan.neon --memory-limit 1G",
8484
"benchmark": "phpbench run --report=aggregate",
8585
"check": [
8686
"@putenv PHP_CS_FIXER_IGNORE_ENV=1",

docs/backends/swoole.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<span style="float:right;"><a href="https://github.com/RubixML/ML/blob/master/src/Backends/Swoole.php">[source]</a></span>
2+
3+
# Swoole
4+
[Swoole](https://swoole.com)/[OpenSwoole](https://openswoole.com/) is an async PHP extension that also supports multiprocessing.
5+
6+
!!! tip
7+
Swoole backend makes use of [Igbinary](https://www.php.net/manual/en/intro.igbinary.php) serializer. If you need to
8+
optimize the memory usage (or getting out-of-memory errors) consider installing [Igbinary](https://www.php.net/manual/en/intro.igbinary.php).
9+
10+
## Example
11+
12+
No parameters are required. It's a drop-in replacement for the [Serial](backends/serial.md) backend.
13+
14+
```php
15+
use Rubix\ML\Backends\Swoole;
16+
17+
$backend = new Swoole();
18+
```

docs/persisters/filesystem.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,37 @@ Filesystems are local or remote storage drives that are organized by files and f
88
|---|---|---|---|---|
99
| 1 | path | | string | The path to the model file on the filesystem. |
1010
| 2 | history | false | bool | Should we keep a history of past saves? |
11-
| 3 | serializer | RBX | Serializer | The serializer used to convert to and from storage format. |
1211

1312
## Example
1413
```php
1514
use Rubix\ML\Persisters\Filesystem;
1615
use Rubix\ML\Serializers\RBX;
16+
use Rubix\ML\Classifiers\KNearestNeighbors;
17+
use Rubix\ML\Kernels\Distance\Manhattan;
1718

18-
$persister = new Filesystem('/path/to/example.model', true, new RBX());
19+
$persistable = new KNearestNeighbors(3, false, new Manhattan());
20+
21+
$persister = new Filesystem('/path/to/example.rbx', true);
22+
23+
$serializer = new RBX(6);
24+
25+
$encoding = $serializer->serialize($persistable);
26+
27+
$persister->save($encoding);
28+
```
29+
30+
## Example
31+
```php
32+
use Rubix\ML\Persisters\Filesystem;
33+
use Rubix\ML\Serializers\RBX;
34+
35+
$persister = new Filesystem('/path/to/example.rbx', true);
36+
37+
$encoding = $persister->load();
38+
39+
$serializer = new RBX(6);
40+
41+
$persistable = $serializer->deserialize($encoding);
1942
```
2043

2144
## Additional Methods

src/AnomalyDetectors/LocalOutlierFactor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class LocalOutlierFactor implements Estimator, Learner, Scoring, Persistable
104104
/**
105105
* @param int $k
106106
* @param float|null $contamination
107-
* @param \Rubix\ML\Graph\Trees\Spatial|null $tree
107+
* @param Spatial|null $tree
108108
* @throws InvalidArgumentException
109109
*/
110110
public function __construct(int $k = 20, ?float $contamination = null, ?Spatial $tree = null)

src/AnomalyDetectors/Loda.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class Loda implements Estimator, Learner, Online, Scoring, Persistable
9898
/**
9999
* The sparse random projection matrix.
100100
*
101-
* @var \Tensor\Matrix|null
101+
* @var Matrix|null
102102
*/
103103
protected ?Matrix $r = null;
104104

src/AnomalyDetectors/OneClassSVM.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ class OneClassSVM implements Estimator, Learner
5656
/**
5757
* The trained model instance.
5858
*
59-
* @var \svmmodel|null
59+
* @var svmmodel|null
6060
*/
6161
protected ?svmmodel $model = null;
6262

6363
/**
6464
* @param float $nu
65-
* @param \Rubix\ML\Kernels\SVM\Kernel|null $kernel
65+
* @param Kernel|null $kernel
6666
* @param bool $shrinking
6767
* @param float $tolerance
6868
* @param float $cacheSize

src/Backends/Swoole.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ function (Process $worker) use ($maxMessageLength, $queueItem) {
9898
true,
9999
);
100100

101-
$workerProcess->setAffinity([$currentCpu]);
101+
if (method_exists($workerProcess, 'setAffinity')) {
102+
$workerProcess->setAffinity([$currentCpu]);
103+
}
104+
102105
$workerProcess->setBlocking(false);
103106
$workerProcess->start();
104107

src/Classifiers/AdaBoost.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class AdaBoost implements Estimator, Learner, Probabilistic, Verbose, Persistabl
145145
protected ?int $featureCount = null;
146146

147147
/**
148-
* @param \Rubix\ML\Learner|null $base
148+
* @param Learner|null $base
149149
* @param float $rate
150150
* @param float $ratio
151151
* @param int $epochs

src/Classifiers/KDNeighbors.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class KDNeighbors implements Estimator, Learner, Probabilistic, Persistable
8181
/**
8282
* @param int $k
8383
* @param bool $weighted
84-
* @param \Rubix\ML\Graph\Trees\Spatial|null $tree
84+
* @param Spatial|null $tree
8585
* @throws InvalidArgumentException
8686
*/
8787
public function __construct(int $k = 5, bool $weighted = false, ?Spatial $tree = null)

src/Classifiers/KNearestNeighbors.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class KNearestNeighbors implements Estimator, Learner, Online, Probabilistic, Pe
9494
/**
9595
* @param int $k
9696
* @param bool $weighted
97-
* @param \Rubix\ML\Kernels\Distance\Distance|null $kernel
97+
* @param Distance|null $kernel
9898
* @throws InvalidArgumentException
9999
*/
100100
public function __construct(int $k = 5, bool $weighted = false, ?Distance $kernel = null)

0 commit comments

Comments
 (0)