Skip to content

Commit dd56e81

Browse files
committed
Merge branch '2.5' into 3.0
2 parents 57e1811 + 0fa98ce commit dd56e81

File tree

108 files changed

+659
-181
lines changed

Some content is hidden

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

108 files changed

+659
-181
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
with:
2121
php-version: ${{ matrix.php-versions }}
2222
tools: composer, pecl
23-
extensions: svm, mbstring, gd, fileinfo
23+
extensions: svm, mbstring, gd, fileinfo, swoole
2424
ini-values: memory_limit=-1
2525

2626
- name: Validate composer.json

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Thumbs.db
88
.DS_Store
99
debug.log
1010
/test.png
11+
pyvenv.cfg
1112
.venv
1213
.idea
1314
.vscode

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
- 2.5.0
1313
- Added Vantage Point Spatial tree
1414
- Blob Generator can now `simulate()` a Dataset object
15+
- Added Wrapper interface
16+
- Added Swoole Backend
17+
- Plus Plus added check for min number of sample seeds
1518

1619
- 2.4.1
1720
- Sentence Tokenizer fix Arabic and Farsi language support

benchmarks/Classifiers/OneVsRestBench.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@
22

33
namespace Rubix\ML\Benchmarks\Classifiers;
44

5+
use Rubix\ML\Backends\Backend;
56
use Rubix\ML\Classifiers\OneVsRest;
67
use Rubix\ML\Datasets\Generators\Blob;
78
use Rubix\ML\Classifiers\LogisticRegression;
89
use Rubix\ML\NeuralNet\Optimizers\Stochastic;
910
use Rubix\ML\Datasets\Generators\Agglomerate;
11+
use Rubix\ML\Tests\DataProvider\BackendProviderTrait;
1012

1113
/**
1214
* @Groups({"Classifiers"})
1315
* @BeforeMethods({"setUp"})
1416
*/
1517
class OneVsRestBench
1618
{
19+
use BackendProviderTrait;
20+
1721
protected const TRAINING_SIZE = 10000;
1822

1923
protected const TESTING_SIZE = 10000;
@@ -52,9 +56,13 @@ public function setUp() : void
5256
* @Subject
5357
* @Iterations(5)
5458
* @OutputTimeUnit("seconds", precision=3)
59+
* @ParamProviders("provideBackends")
60+
* @param array{ backend: Backend } $params
5561
*/
56-
public function trainPredict() : void
62+
public function trainPredict(array $params) : void
5763
{
64+
$this->estimator->setBackend($params['backend']);
65+
5866
$this->estimator->train($this->training);
5967

6068
$this->estimator->predict($this->testing);

benchmarks/Classifiers/RandomForestBench.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@
22

33
namespace Rubix\ML\Benchmarks\Classifiers;
44

5+
use Rubix\ML\Backends\Backend;
56
use Rubix\ML\Classifiers\RandomForest;
67
use Rubix\ML\Datasets\Generators\Blob;
78
use Rubix\ML\Classifiers\ClassificationTree;
89
use Rubix\ML\Datasets\Generators\Agglomerate;
10+
use Rubix\ML\Tests\DataProvider\BackendProviderTrait;
911
use Rubix\ML\Transformers\IntervalDiscretizer;
1012

1113
/**
1214
* @Groups({"Classifiers"})
1315
*/
1416
class RandomForestBench
1517
{
18+
use BackendProviderTrait;
19+
1620
protected const TRAINING_SIZE = 10000;
1721

1822
protected const TESTING_SIZE = 10000;
@@ -70,9 +74,13 @@ public function setUpCategorical() : void
7074
* @Iterations(5)
7175
* @BeforeMethods({"setUpContinuous"})
7276
* @OutputTimeUnit("seconds", precision=3)
77+
* @ParamProviders("provideBackends")
78+
* @param array{ backend: Backend } $params
7379
*/
74-
public function continuous() : void
80+
public function continuous(array $params) : void
7581
{
82+
$this->estimator->setBackend($params['backend']);
83+
7684
$this->estimator->train($this->training);
7785

7886
$this->estimator->predict($this->testing);
@@ -83,9 +91,13 @@ public function continuous() : void
8391
* @Iterations(5)
8492
* @BeforeMethods({"setUpCategorical"})
8593
* @OutputTimeUnit("seconds", precision=3)
94+
* @ParamProviders("provideBackends")
95+
* @param array{ backend: Backend } $params
8696
*/
87-
public function categorical() : void
97+
public function categorical(array $params) : void
8898
{
99+
$this->estimator->setBackend($params['backend']);
100+
89101
$this->estimator->train($this->training);
90102

91103
$this->estimator->predict($this->testing);

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"phpstan/extension-installer": "^1.0",
5050
"phpstan/phpstan": "^1.0",
5151
"phpstan/phpstan-phpunit": "^1.0",
52-
"phpunit/phpunit": "^9.0"
52+
"phpunit/phpunit": "^9.0",
53+
"swoole/ide-helper": "^5.1"
5354
},
5455
"suggest": {
5556
"ext-tensor": "For fast Matrix/Vector computing",

docs/cross-validation/metrics/rand-index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $$
77
{\displaystyle ARI = {\frac {\left.\sum _{ij}{\binom {n_{ij}}{2}}-\left[\sum _{i}{\binom {a_{i}}{2}}\sum _{j}{\binom {b_{j}}{2}}\right]\right/{\binom {n}{2}}}{\left.{\frac {1}{2}}\left[\sum _{i}{\binom {a_{i}}{2}}+\sum _{j}{\binom {b_{j}}{2}}\right]-\left[\sum _{i}{\binom {a_{i}}{2}}\sum _{j}{\binom {b_{j}}{2}}\right]\right/{\binom {n}{2}}}}}
88
$$
99

10-
**Estimator Compatibility:** Regressor
10+
**Estimator Compatibility:** Clusterer
1111

1212
**Score Range:** -1 to 1
1313

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ parameters:
66
- 'benchmarks'
77
excludePaths:
88
- src/Backends/Amp.php
9+
- src/Backends/Swoole.php

phpunit.xml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" forceCoversAnnotation="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
backupGlobals="false"
5+
backupStaticAttributes="false"
6+
bootstrap="vendor/autoload.php"
7+
colors="true"
8+
convertErrorsToExceptions="true"
9+
convertNoticesToExceptions="true"
10+
convertWarningsToExceptions="true"
11+
forceCoversAnnotation="true"
12+
processIsolation="true"
13+
stopOnFailure="false"
14+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
15+
>
316
<coverage processUncoveredFiles="true">
417
<include>
518
<directory suffix=".php">src</directory>

src/AnomalyDetectors/LocalOutlierFactor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class LocalOutlierFactor implements Estimator, Learner, Scoring, Persistable
6767
*
6868
* @var Spatial
6969
*/
70-
protected \Rubix\ML\Graph\Trees\Spatial $tree;
70+
protected Spatial $tree;
7171

7272
/**
7373
* The precomputed k distances between each training sample and its k'th nearest neighbor.

0 commit comments

Comments
 (0)