Skip to content

396 convert regressors to num power#411

Closed
apphp wants to merge 155 commits into
RubixML:3.0from
apphp:396-convert-regressors-to-num-power
Closed

396 convert regressors to num power#411
apphp wants to merge 155 commits into
RubixML:3.0from
apphp:396-convert-regressors-to-num-power

Conversation

@apphp

@apphp apphp commented Mar 28, 2026

Copy link
Copy Markdown

No description provided.

@apphp apphp self-assigned this Mar 28, 2026
@@ -0,0 +1,58 @@
<?php

namespace Rubix\ML\Benchmarks\NeuralNet\ActivationFunctions\ELU;

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.

Let's change the path of this file to reflect it's namespace i.e. remove the ELU folder.

@@ -0,0 +1,58 @@
<?php

namespace Rubix\ML\Benchmarks\NeuralNet\ActivationFunctions\GELU;

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.

The same comment to ELU applies to each of these benchmark files.

* @var Matrix
*/
protected $z;
protected Matrix $z;

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.

Since we are swapping Tensor out for NumPower, we won't need these old benchmarks.

Comment thread src/Clusterers/KMeans.php
// New samples start with provisional label 0 in this partial batch,
// so size bookkeeping must include them before any reassignments.
$this->sizes[0] += $dataset->numSamples();

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.

Why are we making edits to K Means as part of this?

Comment thread src/NeuralNet/Parameters/Parameter.php Outdated
*
* Cloning an NDArray directly may trigger native memory corruption in some
* NumPower builds (e.g. heap corruption/segfaults when parameters are
* snapshotted during training). To make cloning deterministic and stable we

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.

Nice comment!

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

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.

Why are we renaming this class? Will it cause a BC break?

?RegressionLoss $costFn = null,
?Metric $metric = null
?Metric $metric = null,
bool $packSamples = false

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.

Why are we adding this as a constructor argument? Can we autodetect if we need to pack the array instead?

foreach ($distances as $distance) {
$weights[] = 1.0 / (1.0 + $distance);
}
$distances = NumPower::array($distances);

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.

Let's not convert this file to NumPower. It will not benefit as much as others and requires an extra dependency.

Comment thread src/Regressors/SVR.php
* @package Rubix/ML
* @author Andrew DalPino
* @author Samuel Akopyan <leumas.a@gmail.com>
*/

@andrewdalpino andrewdalpino Jul 6, 2026

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.

Let's remove all these @author annotations (including mine). They will become meaningless as time goes on and we can use Git blame if necessary. If the purpose is for recognition, there are probably better ways we can go about it.

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.

Actually on second thought, let's do that in a follow up commit. All good!

Comment thread phpstan-ci.neon
-
message: '#^Property Rubix\\ML\\Classifiers\\NaiveBayes\:\:\$counts \(array<string, list<array<int<0, max>>>>\) does not accept non\-empty\-array<array<array<int<0, max>>>>\.$#'
identifier: assign.propertyType
count: 1

@andrewdalpino andrewdalpino Jul 6, 2026

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.

What is the reason for not using the same phpstan configuration for both local dev and CI?

Comment thread phpstan-bootstrap.php
'float64',
'int8',
'int16',
'int32',

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.

Why do we need these constants?

Comment thread phpstan-baseline.neon Outdated
@@ -19,8 +19,8 @@ parameters:
path: src/NeuralNet/Networks/FeedForward/FeedForward.php

-

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.

What's the reason for this config?

@@ -11,6 +11,10 @@
use Rubix\ML\Exceptions\RuntimeException;
use PHPUnit\Framework\TestCase;

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.

Why are we changing this file as part of this PR?

@@ -6,18 +6,20 @@

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;

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.

Why are we changing this file as part of this PR?

@andrewdalpino andrewdalpino left a comment

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.

Hey @apphp, it looks like there are alot of changes here that don't really have much to do with converting the Regressors to NumPower. Let's revert any changes that aren't necessary to complete the task at hand and we can follower up with other changes in separate PRs.

apphp added 3 commits July 7, 2026 01:06
# Conflicts:
#	benchmarks/NeuralNet/ActivationFunctions/ELUBench.php
#	benchmarks/NeuralNet/ActivationFunctions/GELUBench.php
#	phpstan-baseline.neon
#	phpstan-ci.neon
#	src/NeuralNet/ActivationFunctions/Softmax/Softmax.php
#	src/NeuralNet/Initializers/Normal/Normal.php
#	src/NeuralNet/Initializers/Uniform/Uniform.php
#	src/NeuralNet/Layers/Noise/Noise.php
#	src/NeuralNet/Networks/FeedForward/FeedForward.php
#	src/NeuralNet/Parameters/Parameter.php
#	tests/NeuralNet/CostFunctions/CrossEntropy/CrossEntropyTest.php
#	tests/NeuralNet/CostFunctions/LeastSquares/LeastSquaresTest.php
#	tests/NeuralNet/Initializers/HeUniformTest.php
#	tests/NeuralNet/Initializers/Normal/NormalTest.php
#	tests/NeuralNet/Initializers/TruncatedNormalTest.php
#	tests/NeuralNet/Initializers/XavierNormalTest.php
#	tests/NeuralNet/Initializers/XavierUniformTest.php
@apphp apphp closed this Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants