-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from RubixML/0.4.0-beta
0.4.0 beta
- Loading branch information
Showing
13 changed files
with
453 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ composer.lock | |
.php_cs.cache | ||
Thumbs.db | ||
.DS_Store | ||
debug.log | ||
/.idea | ||
/.vscode | ||
/.vs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace Rubix\ML\Benchmarks\Persisters\Serializers; | ||
|
||
use Rubix\ML\Datasets\Generators\Blob; | ||
use Rubix\ML\Classifiers\KNearestNeighbors; | ||
use Rubix\ML\Datasets\Generators\Agglomerate; | ||
use Rubix\ML\Persisters\Serializers\RBXE; | ||
|
||
/** | ||
* @Groups({"Serializers"}) | ||
* @BeforeMethods({"setUp"}) | ||
*/ | ||
class RBXEBench | ||
{ | ||
protected const TRAINING_SIZE = 2500; | ||
|
||
/** | ||
* @var \Rubix\ML\Persisters\Serializers\RBXE | ||
*/ | ||
protected $serializer; | ||
|
||
/** | ||
* @var \Rubix\ML\Persistable | ||
*/ | ||
protected $persistable; | ||
|
||
public function setUp() : void | ||
{ | ||
$generator = new Agglomerate([ | ||
'Iris-setosa' => new Blob([5.0, 3.42, 1.46, 0.24], [0.35, 0.38, 0.17, 0.1]), | ||
'Iris-versicolor' => new Blob([5.94, 2.77, 4.26, 1.33], [0.51, 0.31, 0.47, 0.2]), | ||
'Iris-virginica' => new Blob([6.59, 2.97, 5.55, 2.03], [0.63, 0.32, 0.55, 0.27]), | ||
]); | ||
|
||
$training = $generator->generate(self::TRAINING_SIZE); | ||
|
||
$estimator = new KNearestNeighbors(5, true); | ||
|
||
$estimator->train($training); | ||
|
||
$this->persistable = $estimator; | ||
|
||
$this->serializer = new RBXE('secret'); | ||
} | ||
|
||
/** | ||
* @Subject | ||
* @revs(10) | ||
* @Iterations(5) | ||
* @OutputTimeUnit("milliseconds", precision=3) | ||
*/ | ||
public function serializeUnserialize() : void | ||
{ | ||
$encoding = $this->serializer->serialize($this->persistable); | ||
|
||
$persistable = $this->serializer->unserialize($encoding); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<span style="float:right;"><a href="https://github.com/RubixML/Extras/blob/master/src/CommitteeMachine.php">[source]</a></span> | ||
|
||
# Committee Machine | ||
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. | ||
|
||
> **Note:** Influence values can be on any arbitrary scale as they are automatically normalized upon instantiation. | ||
**Interfaces:** [Estimator](estimator.md), [Learner](learner.md), [Parallel](parallel.md), [Verbose](verbose.md), [Persistable](persistable.md) | ||
|
||
**Data Type Compatibility:** Depends on the base learners | ||
|
||
## Parameters | ||
| # | Param | Default | Type | Description | | ||
|---|---|---|---|---| | ||
| 1 | experts | | array | An array of learner instances that will comprise the committee. | | ||
| 2 | influences | null | array | The influence values for each expert in the committee. If null, each expert will be weighted equally. | | ||
|
||
## Example | ||
```php | ||
use Rubix\ML\CommitteeMachine; | ||
use Rubix\ML\Classifiers\GaussianNB; | ||
use Rubix\ML\Classifiers\RandomForest; | ||
use Rubix\ML\Classifiers\ClassificationTree; | ||
use Rubix\ML\Classifiers\KDNeighbors; | ||
use Rubix\ML\Classifiers\SoftmaxClassifier; | ||
|
||
$estimator = new CommitteeMachine([ | ||
new GaussianNB(), | ||
new RandomForest(new ClassificationTree(4), 100, 0.3), | ||
new KDNeighbors(3), | ||
new SoftmaxClassifier(100), | ||
], [ | ||
0.2, 0.4, 0.3, 0.1, | ||
]); | ||
``` | ||
|
||
## Additional Methods | ||
Return the learner instances of the committee: | ||
```php | ||
public experts() : array | ||
``` | ||
|
||
Return the normalized influence scores of each expert in the committee: | ||
```php | ||
public influences() : array | ||
``` | ||
|
||
### References | ||
>- [1] H. Drucker. (1997). Fast Committee Machines for Regression and Classification. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<span style="float:right;"><a href="https://github.com/RubixML/Extras/blob/master/src/Persisters/Serializers/RBXE.php">[source]</a></span> | ||
|
||
# RBX Encrypted | ||
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. | ||
|
||
!!! note | ||
Requires the PHP [Open SSL extension](https://www.php.net/manual/en/book.openssl.php) to be installed. | ||
|
||
## Parameters | ||
| # | Param | Default | Type | Description | | ||
|---|---|---|---|---| | ||
| 1 | password | '' | string | The password used to sign and encrypt the data. | | ||
|
||
## Example | ||
```php | ||
use Rubix\ML\Persisters\Serializers\RBXE; | ||
|
||
$serializer = new RBXE('secret'); | ||
``` | ||
|
||
### References | ||
[^1]: H. Krawczyk et al. (1997). HMAC: Keyed-Hashing for Message Authentication. | ||
[^2]: M. Bellare et al. (2007). Authenticated Encryption: Relations among notions and analysis of the generic composition paradigm. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.