Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
556f381
ML-396 migrate Regressors to NumPower
Jul 7, 2026
fd987ef
ML-396 stan check commented in git actions
Jul 7, 2026
6f648b0
ML-396 added rule to phpcs to remove wornings on new_with_parentheses
Jul 7, 2026
c0fd04f
ML-396 restored files structure for phpstan
Jul 7, 2026
a9c633a
ML-396 phpcs fix for Benchmarks\Regressors
Jul 7, 2026
28ac17d
ML-396 phpcs fix for docs\Regressors
Jul 7, 2026
a201bbf
ML-396 fix renamed Xavier1 to XavierNormal
Jul 7, 2026
a63754c
ML-396 reverted changes in AdalineBench for RuntimeException
Jul 9, 2026
11609bb
ML-396 renamed XavierUniform into Xavier1Uniform
Jul 9, 2026
2684f5c
ML-396 fixed NumPower::truncatedNormal() signature
Jul 9, 2026
cf4378e
ML-396 fixed Xavier1Uniform toString value
Jul 9, 2026
0eb5555
ML-396 added Xavier2Uniform
Jul 9, 2026
70aac8b
ML-396 refactored usage of packSamples with global function array_pack
Jul 9, 2026
f97b99e
ML-396 refactored usage of packSamples with global function array_pack
Jul 9, 2026
676416e
ML-396 refactored usage of packSamples with global function array_pack
Jul 9, 2026
9658a9d
ML-396 refactored usage of packSamples with global function array_pack
Jul 9, 2026
3ad90a4
ML-396 improved RidgeTest with different types of tests
Jul 10, 2026
b1fb057
Remove unused depth and maxDepth parameters from array_pack function
samuel-akopyan Jul 20, 2026
e9c4258
ML-396 add Xavier2Normal, rename XavierNormal to Xavier1Normal, and u…
samuel-akopyan Jul 21, 2026
525887e
ML-396 refactoring array_pack
samuel-akopyan Jul 22, 2026
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
17 changes: 17 additions & 0 deletions docs/neural-network/initializers/xavier-1-normal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<span style="float:right;"><a href="https://github.com/RubixML/ML/blob/master/src/NeuralNet/Initializers/Xavier1Normal.php">[source]</a></span>

# Xavier 1 Normal
The Xavier 1 Normal initializer draws from a truncated normal distribution with mean 0 and standard deviation equal to sqrt(2 / (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).

## Parameters
This initializer does not have any parameters.

## Example
```php
use Rubix\ML\NeuralNet\Initializers\Xavier1Normal;

$initializer = new Xavier1Normal();
```

## References
[^1]: X. Glorot et al. (2010). Understanding the Difficulty of Training Deep Feedforward Neural Networks.
17 changes: 17 additions & 0 deletions docs/neural-network/initializers/xavier-1-uniform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<span style="float:right;"><a href="https://github.com/RubixML/ML/blob/master/src/NeuralNet/Initializers/Xavier1Uniform.php">[source]</a></span>

# Xavier 1 Uniform
The Xavier 1 Uniform 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).

## Parameters
This initializer does not have any parameters.

## Example
```php
use Rubix\ML\NeuralNet\Initializers\Xavier1Uniform;

$initializer = new Xavier1Uniform();
```

## References
[^1]: X. Glorot et al. (2010). Understanding the Difficulty of Training Deep Feedforward Neural Networks.
17 changes: 0 additions & 17 deletions docs/neural-network/initializers/xavier-1.md

This file was deleted.

17 changes: 17 additions & 0 deletions docs/neural-network/initializers/xavier-2-normal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<span style="float:right;"><a href="https://github.com/RubixML/ML/blob/master/src/NeuralNet/Initializers/Xavier2Normal.php">[source]</a></span>

# Xavier 2 Normal
The Xavier 2 Normal initializer draws from a truncated normal distribution with mean 0 and standard deviation equal to (2 / (fanIn + fanOut)) ** 0.25. This initializer is best suited for layers that feed into an activation layer that outputs values between -1 and 1 such as [Hyperbolic Tangent](../activation-functions/hyperbolic-tangent.md) and [Softsign](../activation-functions/softsign.md).

## Parameters
This initializer does not have any parameters.

## Example
```php
use Rubix\ML\NeuralNet\Initializers\Xavier2Normal;

$initializer = new Xavier2Normal();
```

## References
[^1]: X. Glorot et al. (2010). Understanding the Difficulty of Training Deep Feedforward Neural Networks.
17 changes: 17 additions & 0 deletions docs/neural-network/initializers/xavier-2-uniform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<span style="float:right;"><a href="https://github.com/RubixML/ML/blob/master/src/NeuralNet/Initializers/Xavier2Uniform.php">[source]</a></span>

# Xavier 2 Uniform
The Xavier 2 Uniform initializer draws from a uniform distribution [-limit, limit] where *limit* is equal to (6 / (fanIn + fanOut)) ** 0.25. This initializer is best suited for layers that feed into an activation layer that outputs values between -1 and 1 such as [Hyperbolic Tangent](../activation-functions/hyperbolic-tangent.md) and [Softsign](../activation-functions/softsign.md).

## Parameters
This initializer does not have any parameters.

## Example
```php
use Rubix\ML\NeuralNet\Initializers\Xavier2Uniform;

$initializer = new Xavier2Uniform();
```

## References
[^1]: X. Glorot et al. (2010). Understanding the Difficulty of Training Deep Feedforward Neural Networks.
17 changes: 0 additions & 17 deletions docs/neural-network/initializers/xavier-2.md

This file was deleted.

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
6 changes: 4 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,10 @@ nav:
- LeCun: neural-network/initializers/lecun.md
- Normal: neural-network/initializers/normal.md
- Uniform: neural-network/initializers/uniform.md
- Xavier 1: neural-network/initializers/xavier-1.md
- Xavier 2: neural-network/initializers/xavier-2.md
- Xavier 1 Uniform: neural-network/initializers/xavier-1-uniform.md
- Xavier 1 Normal: neural-network/initializers/xavier-1-normal.md
- Xavier 2 Uniform: neural-network/initializers/xavier-2-uniform.md
- Xavier 2 Normal: neural-network/initializers/xavier-2-normal.md
- Optimizers:
- AdaGrad: neural-network/optimizers/adagrad.md
- Adam: neural-network/optimizers/adam.md
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
8 changes: 4 additions & 4 deletions src/Classifiers/LogisticRegression.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Rubix\ML\Classifiers;

use Rubix\ML\NeuralNet\FeedForward;
use Rubix\ML\Online;
use Rubix\ML\Learner;
use Rubix\ML\Verbose;
Expand All @@ -19,10 +18,11 @@
use Rubix\ML\NeuralNet\Layers\Dense;
use Rubix\ML\NeuralNet\Layers\Binary;
use Rubix\ML\Traits\AutotrackRevisions;
use Rubix\ML\NeuralNet\Optimizers\Adam;
use Rubix\ML\NeuralNet\FeedForward;
use Rubix\ML\NeuralNet\Initializers\Xavier1Uniform;
use Rubix\ML\NeuralNet\Layers\Placeholder1D;
use Rubix\ML\NeuralNet\Optimizers\Adam;
use Rubix\ML\NeuralNet\Optimizers\Optimizer;
use Rubix\ML\NeuralNet\Initializers\Xavier1;
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 Xavier1Uniform())],
new Binary($classes, $this->costFn),
$this->optimizer
);
Expand Down
6 changes: 3 additions & 3 deletions src/Classifiers/MultilayerPerceptron.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Rubix\ML\Classifiers;

use Rubix\ML\NeuralNet\FeedForward;
use Rubix\ML\Online;
use Rubix\ML\Learner;
use Rubix\ML\Verbose;
Expand All @@ -23,9 +22,10 @@
use Rubix\ML\NeuralNet\Optimizers\Adam;
use Rubix\ML\NeuralNet\Layers\Multiclass;
use Rubix\ML\CrossValidation\Metrics\FBeta;
use Rubix\ML\NeuralNet\FeedForward;
use Rubix\ML\NeuralNet\Initializers\Xavier1Uniform;
use Rubix\ML\NeuralNet\Layers\Placeholder1D;
use Rubix\ML\NeuralNet\Optimizers\Optimizer;
use Rubix\ML\NeuralNet\Initializers\Xavier1;
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 Xavier1Uniform());

$this->network = new FeedForward(
new Placeholder1D($dataset->numFeatures()),
Expand Down
Loading
Loading