Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ jobs:
- name: Run phplint
run: composer phplint

- name: Static Analysis
run: composer analyze
#- name: Static Analysis
# run: composer analyze

- name: Unit Tests
run: composer test
Expand Down
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
],
'native_function_casing' => true,
'native_type_declaration_casing' => true,
'new_expression_parentheses' => false,
'new_with_parentheses' => true,
'no_alternative_syntax' => true,
'no_blank_lines_after_class_opening' => true,
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/Regressors/AdalineBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Rubix\ML\Benchmarks\Regressors;

use Rubix\ML\Datasets\Generators\Hyperplane;
use Rubix\ML\Datasets\Labeled;
use Rubix\ML\Regressors\Adaline;
use Rubix\ML\Datasets\Generators\Hyperplane;

/**
* @Groups({"Regressors"})
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/Regressors/ExtraTreeRegressorBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Rubix\ML\Benchmarks\Regressors;

use Rubix\ML\Datasets\Generators\Hyperplane;
use Rubix\ML\Datasets\Labeled;
use Rubix\ML\Regressors\ExtraTreeRegressor;
use Rubix\ML\Datasets\Generators\Hyperplane;

/**
* @Groups({"Regressors"})
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/Regressors/GradientBoostBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Rubix\ML\Benchmarks\Regressors;

use Rubix\ML\Datasets\Generators\Hyperplane;
use Rubix\ML\Datasets\Labeled;
use Rubix\ML\Regressors\GradientBoost;
use Rubix\ML\Datasets\Generators\Hyperplane;
use Rubix\ML\Transformers\IntervalDiscretizer;

/**
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/Regressors/MLPRegressorBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Rubix\ML\Benchmarks\Regressors;

use Rubix\ML\Datasets\Generators\Hyperplane;
use Rubix\ML\Datasets\Labeled;
use Rubix\ML\NeuralNet\ActivationFunctions\ReLU;
use Rubix\ML\NeuralNet\Layers\Activation;
use Rubix\ML\NeuralNet\Layers\Dense;
use Rubix\ML\Regressors\MLPRegressor;
use Rubix\ML\NeuralNet\Layers\Activation;
use Rubix\ML\Datasets\Generators\Hyperplane;
use Rubix\ML\NeuralNet\ActivationFunctions\ReLU;

/**
* @Groups({"Regressors"})
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/Regressors/RadiusNeighborsRegressorBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Rubix\ML\Benchmarks\Regressors;

use Rubix\ML\Datasets\Generators\Hyperplane;
use Rubix\ML\Datasets\Labeled;
use Rubix\ML\Regressors\RadiusNeighborsRegressor;
use Rubix\ML\Datasets\Generators\Hyperplane;

/**
* @Groups({"Regressors"})
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/Regressors/RidgeBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Rubix\ML\Benchmarks\Regressors;

use Rubix\ML\Datasets\Generators\Hyperplane;
use Rubix\ML\Datasets\Labeled;
use Rubix\ML\Regressors\Ridge;
use Rubix\ML\Datasets\Generators\Hyperplane;

/**
* @Groups({"Regressors"})
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/Regressors/SVRBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Rubix\ML\Benchmarks\Regressors;

use Rubix\ML\Datasets\Generators\Hyperplane;
use Rubix\ML\Datasets\Labeled;
use Rubix\ML\Regressors\SVR;
use Rubix\ML\Datasets\Generators\Hyperplane;

/**
* @Groups({"Regressors"})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<span style="float:right;"><a href="https://github.com/RubixML/ML/blob/master/src/NeuralNet/Initializers/Xavier1.php">[source]</a></span>
<span style="float:right;"><a href="https://github.com/RubixML/ML/blob/master/src/NeuralNet/Initializers/XavierNormal.php">[source]</a></span>

# Xavier 1
The Xavier 1 initializer draws from a uniform distribution [-limit, limit] where *limit* is equal to sqrt(6 / (fanIn + fanOut)). This initializer is best suited for layers that feed into an activation layer that outputs a value between 0 and 1 such as [Softmax](../activation-functions/softmax.md) or [Sigmoid](../activation-functions/sigmoid.md).
Expand All @@ -8,10 +8,10 @@ This initializer does not have any parameters.

## Example
```php
use Rubix\ML\NeuralNet\Initializers\Xavier1;
use Rubix\ML\NeuralNet\Initializers\XavierNormal;

$initializer = new Xavier1();
$initializer = new XavierNormal();
```

## References
[^1]: X. Glorot et al. (2010). Understanding the Difficulty of Training Deep Feedforward Neural Networks.
[^1]: X. Glorot et al. (2010). Understanding the Difficulty of Training Deep Feedforward Neural Networks.
4 changes: 2 additions & 2 deletions docs/regressors/adaline.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

## Example
```php
use Rubix\ML\Regressors\Adaline;
use Rubix\ML\NeuralNet\Optimizers\Adam;
use Rubix\ML\NeuralNet\CostFunctions\HuberLoss;
use Rubix\ML\NeuralNet\Optimizers\Adam;
use Rubix\ML\Regressors\Adaline;

$estimator = new Adaline(256, new Adam(0.001), 1e-4, 500, 1e-6, 5, new HuberLoss(2.5));
```
Expand Down
2 changes: 1 addition & 1 deletion docs/regressors/gradient-boost.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ Gradient Boost (GBM) is a stage-wise additive ensemble that uses a Gradient Desc

## Example
```php
use Rubix\ML\CrossValidation\Metrics\SMAPE;
use Rubix\ML\Regressors\GradientBoost;
use Rubix\ML\Regressors\RegressionTree;
use Rubix\ML\CrossValidation\Metrics\SMAPE;

$estimator = new GradientBoost(new RegressionTree(3), 0.1, 0.8, 1000, 1e-4, 3, 10, 0.1, new SMAPE());
```
Expand Down
8 changes: 4 additions & 4 deletions docs/regressors/mlp-regressor.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ A multilayer feed-forward neural network with a continuous output layer suitable

## Example
```php
use Rubix\ML\Regressors\MLPRegressor;
use Rubix\ML\CrossValidation\Metrics\RSquared;
use Rubix\ML\NeuralNet\ActivationFunctions\ReLU;
use Rubix\ML\NeuralNet\CostFunctions\LeastSquares;
use Rubix\ML\NeuralNet\Layers\Dense;
use Rubix\ML\NeuralNet\Layers\Activation;
use Rubix\ML\NeuralNet\ActivationFunctions\ReLU;
use Rubix\ML\NeuralNet\Layers\Dense;
use Rubix\ML\NeuralNet\Optimizers\RMSProp;
use Rubix\ML\CrossValidation\Metrics\RSquared;
use Rubix\ML\Regressors\MLPRegressor;

$estimator = new MLPRegressor([
new Dense(100),
Expand Down
2 changes: 1 addition & 1 deletion docs/regressors/radius-neighbors-regressor.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ This is the regressor version of [Radius Neighbors](../classifiers/radius-neighb

## Example
```php
use Rubix\ML\Regressors\RadiusNeighborsRegressor;
use Rubix\ML\Graph\Trees\BallTree;
use Rubix\ML\Kernels\Distance\Diagonal;
use Rubix\ML\Regressors\RadiusNeighborsRegressor;

$estimator = new RadiusNeighborsRegressor(0.5, false, new BallTree(30, new Diagonal()));
```
Expand Down
2 changes: 1 addition & 1 deletion docs/regressors/regression-tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ public balance() : ?int

## References:
[^1]: W. Y. Loh. (2011). Classification and Regression Trees.
[^2]: K. Alsabti. et al. (1998). CLOUDS: A Decision Tree Classifier for Large Datasets.
[^2]: K. Alsabti. et al. (1998). CLOUDS: A Decision Tree Classifier for Large Datasets.
2 changes: 1 addition & 1 deletion docs/regressors/svr.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public load(string $path) : void

## Example
```php
use Rubix\ML\Regressors\SVR;
use Rubix\ML\Kernels\SVM\RBF;
use Rubix\ML\Regressors\SVR;

$estimator = new SVR(1.0, 0.03, new RBF(), true, 1e-3, 256.0);
```
Expand Down
9 changes: 9 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
parameters:
ignoreErrors:
# Add here all the errors that you want to ignore
# -----------------------------------------------
# -
# message: '#^Method Rubix\\ML\\BootstrapAggregator\:\:params\(\) return type has no value type specified in iterable type array\.$#'
# identifier: missingType.iterableValue
# count: 1
# path: src/BootstrapAggregator.php
25 changes: 25 additions & 0 deletions phpstan-bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

// NumPower dtype names are used as constants across the codebase.
// During static analysis these constants may not exist, so we define them here
// to prevent undefined constant errors in PHPStan.
Comment thread
apphp marked this conversation as resolved.
foreach ([
'float16',
'float32',
'float64',
'int8',
'int16',
'int32',
'int64',
'uint8',
'uint16',
'uint32',
'uint64',
'bool',
] as $dtype) {
if (!defined($dtype)) {
define($dtype, $dtype);
}
}
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ includes:
parameters:
level: 8
phpVersion: 80400
bootstrapFiles:
- phpstan-bootstrap.php
fileExtensions:
- php
tmpDir: ./runtime/.phpstan/
Expand Down
4 changes: 2 additions & 2 deletions src/Classifiers/LogisticRegression.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use Rubix\ML\NeuralNet\Optimizers\Adam;
use Rubix\ML\NeuralNet\Layers\Placeholder1D;
use Rubix\ML\NeuralNet\Optimizers\Optimizer;
use Rubix\ML\NeuralNet\Initializers\Xavier1;
use Rubix\ML\NeuralNet\Initializers\XavierNormal;
use Rubix\ML\Specifications\DatasetIsLabeled;
use Rubix\ML\Specifications\DatasetIsNotEmpty;
use Rubix\ML\Specifications\SpecificationChain;
Expand Down Expand Up @@ -292,7 +292,7 @@ public function train(Dataset $dataset) : void

$this->network = new FeedForward(
new Placeholder1D($dataset->numFeatures()),
[new Dense(1, $this->l2Penalty, true, new Xavier1())],
[new Dense(1, $this->l2Penalty, true, new XavierNormal())],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XavierNormal is not equivalent to Xavier1 which samples from a uniform distribution.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with using Xavier1Uniform

new Binary($classes, $this->costFn),
$this->optimizer
);
Expand Down
4 changes: 2 additions & 2 deletions src/Classifiers/MultilayerPerceptron.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use Rubix\ML\CrossValidation\Metrics\FBeta;
use Rubix\ML\NeuralNet\Layers\Placeholder1D;
use Rubix\ML\NeuralNet\Optimizers\Optimizer;
use Rubix\ML\NeuralNet\Initializers\Xavier1;
use Rubix\ML\NeuralNet\Initializers\XavierNormal;
use Rubix\ML\CrossValidation\Metrics\Metric;
use Rubix\ML\Specifications\DatasetIsLabeled;
use Rubix\ML\Specifications\DatasetIsNotEmpty;
Expand Down Expand Up @@ -369,7 +369,7 @@ public function train(Dataset $dataset) : void

$hiddenLayers = $this->hiddenLayers;

$hiddenLayers[] = new Dense(count($classes), 0.0, true, new Xavier1());
$hiddenLayers[] = new Dense(count($classes), 0.0, true, new XavierNormal());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XavierNormal is not equivalent to Xavier1 which samples from a uniform distribution.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with using Xavier1Uniform


$this->network = new FeedForward(
new Placeholder1D($dataset->numFeatures()),
Expand Down
4 changes: 2 additions & 2 deletions src/Classifiers/SoftmaxClassifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use Rubix\ML\NeuralNet\Layers\Multiclass;
use Rubix\ML\NeuralNet\Layers\Placeholder1D;
use Rubix\ML\NeuralNet\Optimizers\Optimizer;
use Rubix\ML\NeuralNet\Initializers\Xavier1;
use Rubix\ML\NeuralNet\Initializers\XavierNormal;
use Rubix\ML\Specifications\DatasetIsLabeled;
use Rubix\ML\Specifications\DatasetIsNotEmpty;
use Rubix\ML\Specifications\SpecificationChain;
Expand Down Expand Up @@ -288,7 +288,7 @@ public function train(Dataset $dataset) : void

$this->network = new FeedForward(
new Placeholder1D($dataset->numFeatures()),
[new Dense(count($classes), $this->l2Penalty, true, new Xavier1())],
[new Dense(count($classes), $this->l2Penalty, true, new XavierNormal())],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XavierNormal is not equivalent to Xavier1 which samples from a uniform distribution.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with Xavier1Uniform

new Multiclass($classes, $this->costFn),
$this->optimizer
);
Expand Down
1 change: 1 addition & 0 deletions src/NeuralNet/Optimizers/Momentum.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use NDArray;
use NumPower;
use Rubix\ML\Helpers\Params;
use Rubix\ML\NeuralNet\Parameter;
use Rubix\ML\Exceptions\InvalidArgumentException;
use Rubix\ML\Exceptions\RuntimeException;
Expand Down
Loading
Loading