-
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial commit (#299) * Vantage Tree (#300) * Initial commit * Better testing * Improve the docs * Rename benchmark * Explicitly import max() function * Fix coding style * Wrapper interface (#314) * Add Wrapper interface for models wrappers * Add WrapperAware trait * Fix PhpDoc * Revert "Add WrapperAware trait" This reverts commit 241abc4. * Rename Wrapper interface to EstimatorWrapper * PHP CS fix * Swoole Backend (#312) * add Swoole backend * phpstan: ignore swoole * feat: swoole process scheduler * fix(swoole): redo tasks when hash collision happens * chore(swoole): make sure coroutines are at the root of the scheduler * chore(swoole): set affinity / bind worker to a specific CPU core * chore(swoole): use igbinary if available * fix: remove comment * fix(swoole): worker cpu affinity * fix(swoole): cpu num * feat: scheduler improvements * style * chore(swoole): remove unnecessary atomics * chore(swoole): php backwards compatibility * fix: phpstan, socket message size * fix: uncomment test * style: composer fix * Plus plus check (#317) * Initial commit * Allow deltas in units tests * Swoole docs (#326) * add Swoole backend * phpstan: ignore swoole * feat: swoole process scheduler * fix(swoole): redo tasks when hash collision happens * chore(swoole): make sure coroutines are at the root of the scheduler * chore(swoole): set affinity / bind worker to a specific CPU core * chore(swoole): use igbinary if available * fix: remove comment * fix(swoole): worker cpu affinity * fix(swoole): cpu num * feat: scheduler improvements * style * chore(swoole): remove unnecessary atomics * chore(swoole): php backwards compatibility * fix: phpstan, socket message size * fix: uncomment test * style: composer fix * docs: Swoole backend * Fix coding style and composer.lock * fix(swoole): setAffinity does not exist on some versions of Swoole (#327) * Back out Swoole Backend code * Bump version --------- Co-authored-by: Ronan Giron <ElGigi@users.noreply.github.com> Co-authored-by: Mateusz Charytoniuk <mateusz.charytoniuk@protonmail.com>
- Loading branch information
1 parent
696a2f6
commit d43a5f2
Showing
32 changed files
with
926 additions
and
39 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Rubix\ML\Benchmarks\Graph\Trees; | ||
|
||
use Rubix\ML\Graph\Trees\VantageTree; | ||
use Rubix\ML\Datasets\Generators\Blob; | ||
use Rubix\ML\Datasets\Generators\Agglomerate; | ||
|
||
/** | ||
* @Groups({"Trees"}) | ||
* @BeforeMethods({"setUp"}) | ||
*/ | ||
class VantageTreeBench | ||
{ | ||
protected const DATASET_SIZE = 10000; | ||
|
||
/** | ||
* @var \Rubix\ML\Datasets\Labeled; | ||
*/ | ||
protected $dataset; | ||
|
||
/** | ||
* @var VantageTree | ||
*/ | ||
protected $tree; | ||
|
||
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]), | ||
]); | ||
|
||
$this->dataset = $generator->generate(self::DATASET_SIZE); | ||
|
||
$this->tree = new VantageTree(30); | ||
} | ||
|
||
/** | ||
* @Subject | ||
* @Iterations(3) | ||
* @OutputTimeUnit("seconds", precision=3) | ||
*/ | ||
public function grow() : void | ||
{ | ||
$this->tree->grow($this->dataset); | ||
} | ||
} |
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,28 @@ | ||
<span style="float:right;"><a href="https://github.com/RubixML/ML/blob/master/src/Graph/Trees/VPTree.php">[source]</a></span> | ||
|
||
# Vantage Tree | ||
A Vantage Point Tree is a binary spatial tree that divides samples by their distance from the center of a cluster called the *vantage point*. Samples that are closer to the vantage point will be put into one branch of the tree while samples that are farther away will be put into the other branch. | ||
|
||
**Interfaces:** Binary Tree, Spatial | ||
|
||
**Data Type Compatibility:** Depends on distance kernel | ||
|
||
## Parameters | ||
| # | Param | Default | Type | Description | | ||
|---|---|---|---|---| | ||
| 1 | max leaf size | 30 | int | The maximum number of samples that each leaf node can contain. | | ||
| 2 | kernel | Euclidean | Distance | The distance kernel used to compute the distance between sample points. | | ||
|
||
## Example | ||
```php | ||
use Rubix\ML\Graph\Trees\VantageTree; | ||
use Rubix\ML\Kernels\Distance\Euclidean; | ||
|
||
$tree = new VantageTree(30, new Euclidean()); | ||
``` | ||
|
||
## Additional Methods | ||
This tree does not have any additional methods. | ||
|
||
### References | ||
>- P. N. Yianilos. (1993). Data Structures and Algorithms for Nearest Neighbor Search in General Metric Spaces. |
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
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,20 @@ | ||
<?php | ||
|
||
namespace Rubix\ML; | ||
|
||
/** | ||
* Wrapper | ||
* | ||
* @category Machine Learning | ||
* @package Rubix/ML | ||
* @author Ronan Giron | ||
*/ | ||
interface EstimatorWrapper extends Estimator | ||
{ | ||
/** | ||
* Return the base estimator instance. | ||
* | ||
* @return Estimator | ||
*/ | ||
public function base() : Estimator; | ||
} |
Oops, something went wrong.