Skip to content
This repository was archived by the owner on Mar 28, 2025. It is now read-only.

Commit 57f375e

Browse files
Merge pull request #8 from RubixML/0.4.0-beta
0.4.0 beta
2 parents c13d29e + 702cd9e commit 57f375e

13 files changed

Lines changed: 453 additions & 164 deletions

File tree

.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: pecl
23-
extensions: bz2, fileinfo
23+
extensions: fileinfo
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
@@ -4,6 +4,7 @@ composer.lock
44
.php_cs.cache
55
Thumbs.db
66
.DS_Store
7+
debug.log
78
/.idea
89
/.vscode
910
/.vs

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
- 0.4.0-beta
2+
- Added RBXE serializer
3+
- Removed Bzip2 serailizer
4+
15
- 0.3.0-beta
26
- Added Vantage Point Tree for spatial queries
3-
- Added Bzip2 serializers
7+
- Added Bzip2 serializer
48
- Added Levenshtein distance kernel
59
- Move K Best Selector to main repository
610
- Added custom exceptions from the main repo

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Rubix ML Extras
2-
Experimental features for the Rubix ML library. The code here can see major changes or even removal. If/when features reach 1- sufficient maturity/stability and 2- sufficient community interest, they will be moved to the main package.
2+
Experimental features for the Rubix ML library. The code here is in permanent beta and may be moved or removed in future releases.
33

44
## Installation
55
Install into your project using [Composer](https://getcomposer.org/):
@@ -10,8 +10,5 @@ $ composer require rubix/extras
1010
### Requirements
1111
- [PHP](https://php.net/manual/en/install.php) 7.2 or above
1212

13-
##### Optional
14-
- [Bzip2 extension](https://www.php.net/manual/en/book.bzip2.php) for Bzip2 compression
15-
1613
## License
1714
The code is licensed [MIT](LICENSE) and the documentation is licensed [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/).
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
namespace Rubix\ML\Benchmarks\Persisters\Serializers;
4+
5+
use Rubix\ML\Datasets\Generators\Blob;
6+
use Rubix\ML\Classifiers\KNearestNeighbors;
7+
use Rubix\ML\Datasets\Generators\Agglomerate;
8+
use Rubix\ML\Persisters\Serializers\RBXE;
9+
10+
/**
11+
* @Groups({"Serializers"})
12+
* @BeforeMethods({"setUp"})
13+
*/
14+
class RBXEBench
15+
{
16+
protected const TRAINING_SIZE = 2500;
17+
18+
/**
19+
* @var \Rubix\ML\Persisters\Serializers\RBXE
20+
*/
21+
protected $serializer;
22+
23+
/**
24+
* @var \Rubix\ML\Persistable
25+
*/
26+
protected $persistable;
27+
28+
public function setUp() : void
29+
{
30+
$generator = new Agglomerate([
31+
'Iris-setosa' => new Blob([5.0, 3.42, 1.46, 0.24], [0.35, 0.38, 0.17, 0.1]),
32+
'Iris-versicolor' => new Blob([5.94, 2.77, 4.26, 1.33], [0.51, 0.31, 0.47, 0.2]),
33+
'Iris-virginica' => new Blob([6.59, 2.97, 5.55, 2.03], [0.63, 0.32, 0.55, 0.27]),
34+
]);
35+
36+
$training = $generator->generate(self::TRAINING_SIZE);
37+
38+
$estimator = new KNearestNeighbors(5, true);
39+
40+
$estimator->train($training);
41+
42+
$this->persistable = $estimator;
43+
44+
$this->serializer = new RBXE('secret');
45+
}
46+
47+
/**
48+
* @Subject
49+
* @revs(10)
50+
* @Iterations(5)
51+
* @OutputTimeUnit("milliseconds", precision=3)
52+
*/
53+
public function serializeUnserialize() : void
54+
{
55+
$encoding = $this->serializer->serialize($this->persistable);
56+
57+
$persistable = $this->serializer->unserialize($encoding);
58+
}
59+
}

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
],
2323
"require": {
2424
"php": ">=7.2",
25-
"rubix/ml": "0.3.0",
26-
"rubix/tensor": "^2.0.4",
25+
"rubix/ml": "^0.4.0",
26+
"rubix/tensor": "^2.2",
2727
"wamania/php-stemmer": "^2.0"
2828
},
2929
"require-dev": {
3030
"friendsofphp/php-cs-fixer": "2.18.*",
31-
"phpbench/phpbench": "1.0.0-alpha4",
31+
"phpbench/phpbench": "1.0.0-alpha6",
3232
"phpstan/extension-installer": "^1.0",
3333
"phpstan/phpstan": "0.12.*",
3434
"phpstan/phpstan-phpunit": "0.12.*",

docs/model-orchestra.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<span style="float:right;"><a href="https://github.com/RubixML/Extras/blob/master/src/CommitteeMachine.php">[source]</a></span>
2+
3+
# Committee Machine
4+
A voting ensemble that aggregates the predictions of a committee of heterogeneous learners (referred to as *experts*). The committee employs a user-specified influence scheme to weight the final predictions.
5+
6+
> **Note:** Influence values can be on any arbitrary scale as they are automatically normalized upon instantiation.
7+
8+
**Interfaces:** [Estimator](estimator.md), [Learner](learner.md), [Parallel](parallel.md), [Verbose](verbose.md), [Persistable](persistable.md)
9+
10+
**Data Type Compatibility:** Depends on the base learners
11+
12+
## Parameters
13+
| # | Param | Default | Type | Description |
14+
|---|---|---|---|---|
15+
| 1 | experts | | array | An array of learner instances that will comprise the committee. |
16+
| 2 | influences | null | array | The influence values for each expert in the committee. If null, each expert will be weighted equally. |
17+
18+
## Example
19+
```php
20+
use Rubix\ML\CommitteeMachine;
21+
use Rubix\ML\Classifiers\GaussianNB;
22+
use Rubix\ML\Classifiers\RandomForest;
23+
use Rubix\ML\Classifiers\ClassificationTree;
24+
use Rubix\ML\Classifiers\KDNeighbors;
25+
use Rubix\ML\Classifiers\SoftmaxClassifier;
26+
27+
$estimator = new CommitteeMachine([
28+
new GaussianNB(),
29+
new RandomForest(new ClassificationTree(4), 100, 0.3),
30+
new KDNeighbors(3),
31+
new SoftmaxClassifier(100),
32+
], [
33+
0.2, 0.4, 0.3, 0.1,
34+
]);
35+
```
36+
37+
## Additional Methods
38+
Return the learner instances of the committee:
39+
```php
40+
public experts() : array
41+
```
42+
43+
Return the normalized influence scores of each expert in the committee:
44+
```php
45+
public influences() : array
46+
```
47+
48+
### References
49+
>- [1] H. Drucker. (1997). Fast Committee Machines for Regression and Classification.

docs/persisters/Serializers/bzip2.md

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<span style="float:right;"><a href="https://github.com/RubixML/Extras/blob/master/src/Persisters/Serializers/RBXE.php">[source]</a></span>
2+
3+
# RBX Encrypted
4+
Encrypted Rubix Object File format (RBXE) is a format to securely store and share serialized PHP objects. In addition to ensuring data integrity like RBX format, RBXE also adds layers of security such as tamper protection and data encryption while being resilient to brute-force and evasive to timing attacks.
5+
6+
!!! note
7+
Requires the PHP [Open SSL extension](https://www.php.net/manual/en/book.openssl.php) to be installed.
8+
9+
## Parameters
10+
| # | Param | Default | Type | Description |
11+
|---|---|---|---|---|
12+
| 1 | password | '' | string | The password used to sign and encrypt the data. |
13+
14+
## Example
15+
```php
16+
use Rubix\ML\Persisters\Serializers\RBXE;
17+
18+
$serializer = new RBXE('secret');
19+
```
20+
21+
### References
22+
[^1]: H. Krawczyk et al. (1997). HMAC: Keyed-Hashing for Message Authentication.
23+
[^2]: M. Bellare et al. (2007). Authenticated Encryption: Relations among notions and analysis of the generic composition paradigm.

src/ModelOrchestra.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Rubix\ML\Backends\Tasks\TrainLearner;
1616
use Rubix\ML\Other\Traits\Multiprocessing;
1717
use Rubix\ML\Classifiers\SoftmaxClassifier;
18+
use Rubix\ML\Other\Traits\AutotrackRevisions;
1819
use Rubix\ML\Specifications\DatasetIsNotEmpty;
1920
use Rubix\ML\Specifications\SpecificationChain;
2021
use Rubix\ML\Specifications\SamplesAreCompatibleWithEstimator;
@@ -36,7 +37,7 @@
3637
*/
3738
class ModelOrchestra implements Learner, Parallel, Persistable, Verbose
3839
{
39-
use Multiprocessing, PredictsSingle, LoggerAware;
40+
use AutotrackRevisions, Multiprocessing, PredictsSingle, LoggerAware;
4041

4142
/**
4243
* The members of the orchestra.

0 commit comments

Comments
 (0)