Skip to content

396 convert regressors to num power#411

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

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

Conversation

@apphp
Copy link
Copy Markdown

@apphp apphp commented Mar 28, 2026

No description provided.

@apphp apphp self-assigned this Mar 28, 2026
@apphp apphp closed this May 10, 2026
@apphp apphp reopened this May 10, 2026
@apphp apphp requested a review from andrewdalpino May 25, 2026 21:48
Copy link
Copy Markdown
Member

@andrewdalpino andrewdalpino left a comment

Choose a reason for hiding this comment

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

Left some comment @apphp, will continue the review sometime in the future.

Comment thread .github/workflows/ci.yml
run: composer analyze-ci

- name: Unit Tests
#run: vendor/bin/phpunit --display-warning --display-deprecations --display-notices --testsuite="Anomaly Detectors,Backends,Base,Classifiers,Clusterers,Cross Validation,Datasets,Extractors,Graph,Helpers,Kernels,Loggers,NeuralNet,Persisters,Regressors,Serializers,Specifications,Strategies,Tokenizers,Transformers"
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 purpose of this line?

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.

Just possibility to run tests separately. Sometimes they failed on GitHub, so to save time I can run only problematic section. If you don't like it - I can remove this line.

@@ -1,4 +1,4 @@
<span style="float:right;"><a href="https://github.com/RubixML/ML/blob/master/src/Datasets/Generators/Hyperplane.php">[source]</a></span>
<span style="float:right;"><a href="https://github.com/RubixML/ML/blob/master/src/Datasets/Generators/Hyperplane/Hyperplane.php">[source]</a></span>
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.

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.

Why? This is a new class for migration to NumPower. Currently we store old files (Martix) and new (NumPower) approach. If you decide to remove old files at all before release, so yes - this will go back before final release of v3.0

{
$samples = $labels = [];

$counts = NumPower::round(NumPower::multiply($this->weights, $n), 0)->toArray();
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 using numpower instead of PHP here? Is it justified?

Copy link
Copy Markdown
Author

@apphp apphp May 30, 2026

Choose a reason for hiding this comment

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

No, you're right. I used $this->weights as NDArray, that's why I was needed to changed this method.
But I've redefined $this->weights as array (like in original class) and now generate() methods looks exactly like in previous class.

*
* @var NDArray
*/
protected NDArray $weights;
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.

Does this need to be a NumPower array?

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.

No, turned back and fixed.

}
}

if (is_array($weights)) {
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 stick to either a PHP array or a NumPower array in the API, but not both.

Copy link
Copy Markdown
Author

@apphp apphp May 30, 2026

Choose a reason for hiding this comment

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

Fixed back to original version - array


$weights = NumPower::divide($weights, $total);
} else {
$weights = NumPower::array(array_fill(0, $k, 1.0 / $k));
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.

Do we not need any of the bounds checking for NumPower like we do above with a PHP array?

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.

I just tried to stay on original file code:

          foreach ($weights as &$weight) {
              $weight /= $total;
          }
      } else {
          $weights = array_fill(0, $k, 1.0 / $k);
      }

Comment thread src/Datasets/Generators/Blob/Blob.php Outdated

$samples = NumPower::add(
NumPower::multiply(
NumPower::normal(size: [$n, $d], loc: 0.0, scale: 1.0),
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 does the loc argument do here? Is it some type of offset?

Copy link
Copy Markdown
Author

@apphp apphp May 30, 2026

Choose a reason for hiding this comment

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

This is just a default parameter with default values - removed.
@param int|float|string $loc Mean (µ); default 0.0.

@@ -0,0 +1,116 @@
<?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.

Have you tried plotting the output of these Generators as a sanity check?

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.

No. Can you explain me how to do that?

@apphp apphp closed this May 30, 2026
@apphp apphp reopened this May 30, 2026
@apphp apphp closed this May 30, 2026
@apphp apphp reopened this May 30, 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