Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move tools to a separate directory #316

Open
wants to merge 5 commits into
base: 3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge remote-tracking branch 'rubixml/3.0' into tools
  • Loading branch information
mcharytoniuk committed Feb 26, 2024
commit a79151d2fdeacdb03ba960231ba860d1206e5239
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
php-version: ${{ matrix.php-versions }}
tools: composer, pecl
extensions: svm, mbstring, gd, fileinfo
extensions: svm, mbstring, gd, fileinfo, swoole
ini-values: memory_limit=-1

- name: Validate composer.json
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Thumbs.db
.DS_Store
debug.log
/test.png
pyvenv.cfg
.venv
.idea
.vscode
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,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
10 changes: 9 additions & 1 deletion benchmarks/Classifiers/OneVsRestBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@

namespace Rubix\ML\Benchmarks\Classifiers;

use Rubix\ML\Backends\Backend;
use Rubix\ML\Classifiers\OneVsRest;
use Rubix\ML\Datasets\Generators\Blob;
use Rubix\ML\Classifiers\LogisticRegression;
use Rubix\ML\NeuralNet\Optimizers\Stochastic;
use Rubix\ML\Datasets\Generators\Agglomerate;
use Rubix\ML\Tests\DataProvider\BackendProviderTrait;

/**
* @Groups({"Classifiers"})
* @BeforeMethods({"setUp"})
*/
class OneVsRestBench
{
use BackendProviderTrait;

protected const TRAINING_SIZE = 10000;

protected const TESTING_SIZE = 10000;
Expand Down Expand Up @@ -45,16 +49,20 @@

$this->testing = $generator->generate(self::TESTING_SIZE);

$this->estimator = new OneVsRest(new LogisticRegression(64, new Stochastic(0.001)));

Check failure on line 52 in benchmarks/Classifiers/OneVsRestBench.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 on ubuntu-latest

Instantiated class Rubix\ML\Classifiers\LogisticRegression not found.

Check failure on line 52 in benchmarks/Classifiers/OneVsRestBench.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 on ubuntu-latest

Parameter #1 $base of class Rubix\ML\Classifiers\OneVsRest constructor expects Rubix\ML\Learner, Rubix\ML\Classifiers\LogisticRegression given.

Check failure on line 52 in benchmarks/Classifiers/OneVsRestBench.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 on ubuntu-latest

Instantiated class Rubix\ML\Classifiers\LogisticRegression not found.

Check failure on line 52 in benchmarks/Classifiers/OneVsRestBench.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 on ubuntu-latest

Parameter #1 $base of class Rubix\ML\Classifiers\OneVsRest constructor expects Rubix\ML\Learner, Rubix\ML\Classifiers\LogisticRegression given.

Check failure on line 52 in benchmarks/Classifiers/OneVsRestBench.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 on macos-latest

Instantiated class Rubix\ML\Classifiers\LogisticRegression not found.

Check failure on line 52 in benchmarks/Classifiers/OneVsRestBench.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 on macos-latest

Parameter #1 $base of class Rubix\ML\Classifiers\OneVsRest constructor expects Rubix\ML\Learner, Rubix\ML\Classifiers\LogisticRegression given.

Check failure on line 52 in benchmarks/Classifiers/OneVsRestBench.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 on macos-latest

Instantiated class Rubix\ML\Classifiers\LogisticRegression not found.

Check failure on line 52 in benchmarks/Classifiers/OneVsRestBench.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 on macos-latest

Parameter #1 $base of class Rubix\ML\Classifiers\OneVsRest constructor expects Rubix\ML\Learner, Rubix\ML\Classifiers\LogisticRegression given.
}

/**
* @Subject
* @Iterations(5)
* @OutputTimeUnit("seconds", precision=3)
* @ParamProviders("provideBackends")
* @param array{ backend: Backend } $params
*/
public function trainPredict() : void
public function trainPredict(array $params) : void
{
$this->estimator->setBackend($params['backend']);

$this->estimator->train($this->training);

$this->estimator->predict($this->testing);
Expand Down
16 changes: 14 additions & 2 deletions benchmarks/Classifiers/RandomForestBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@

namespace Rubix\ML\Benchmarks\Classifiers;

use Rubix\ML\Backends\Backend;
use Rubix\ML\Classifiers\RandomForest;
use Rubix\ML\Datasets\Generators\Blob;
use Rubix\ML\Classifiers\ClassificationTree;
use Rubix\ML\Datasets\Generators\Agglomerate;
use Rubix\ML\Tests\DataProvider\BackendProviderTrait;
use Rubix\ML\Transformers\IntervalDiscretizer;

/**
* @Groups({"Classifiers"})
*/
class RandomForestBench
{
use BackendProviderTrait;

protected const TRAINING_SIZE = 10000;

protected const TESTING_SIZE = 10000;
Expand Down Expand Up @@ -70,9 +74,13 @@ public function setUpCategorical() : void
* @Iterations(5)
* @BeforeMethods({"setUpContinuous"})
* @OutputTimeUnit("seconds", precision=3)
* @ParamProviders("provideBackends")
* @param array{ backend: Backend } $params
*/
public function continuous() : void
public function continuous(array $params) : void
{
$this->estimator->setBackend($params['backend']);

$this->estimator->train($this->training);

$this->estimator->predict($this->testing);
Expand All @@ -83,9 +91,13 @@ public function continuous() : void
* @Iterations(5)
* @BeforeMethods({"setUpCategorical"})
* @OutputTimeUnit("seconds", precision=3)
* @ParamProviders("provideBackends")
* @param array{ backend: Backend } $params
*/
public function categorical() : void
public function categorical(array $params) : void
{
$this->estimator->setBackend($params['backend']);

$this->estimator->train($this->training);

$this->estimator->predict($this->testing);
Expand Down
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"wamania/php-stemmer": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0"
"phpunit/phpunit": "^9.0",
"swoole/ide-helper": "^5.1"
},
"suggest": {
"ext-tensor": "For fast Matrix/Vector computing",
Expand Down Expand Up @@ -104,7 +105,11 @@
},
"config": {
"preferred-install": "dist",
"sort-packages": true
"sort-packages": true,
"process-timeout": 3000,
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"funding": [
{
Expand Down
70 changes: 51 additions & 19 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/cross-validation/metrics/rand-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $$
{\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}}}}}
$$

**Estimator Compatibility:** Regressor
**Estimator Compatibility:** Clusterer

**Score Range:** -1 to 1

Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ parameters:
- 'benchmarks'
excludePaths:
- src/Backends/Amp.php
- src/Backends/Swoole.php
15 changes: 14 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="https://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">
<phpunit
xmlns:xsi="https://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="true"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
Expand Down
2 changes: 1 addition & 1 deletion src/AnomalyDetectors/LocalOutlierFactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class LocalOutlierFactor implements Estimator, Learner, Scoring, Persistable
*
* @var Spatial
*/
protected \Rubix\ML\Graph\Trees\Spatial $tree;
protected Spatial $tree;

/**
* The precomputed k distances between each training sample and its k'th nearest neighbor.
Expand Down
2 changes: 1 addition & 1 deletion src/AnomalyDetectors/Loda.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Loda implements Estimator, Learner, Online, Scoring, Persistable
*
* @var \Tensor\Matrix|null
*/
protected ?\Tensor\Matrix $r = null;
protected ?Matrix $r = null;

/**
* The edges and bin counts of each histogram.
Expand Down
4 changes: 2 additions & 2 deletions src/AnomalyDetectors/OneClassSVM.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class OneClassSVM implements Estimator, Learner
*
* @var svm
*/
protected \svm $svm;
protected svm $svm;

/**
* The hyper-parameters of the model.
Expand All @@ -58,7 +58,7 @@ class OneClassSVM implements Estimator, Learner
*
* @var \svmmodel|null
*/
protected ?\svmmodel $model = null;
protected ?svmmodel $model = null;

/**
* @param float $nu
Expand Down
Loading
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.