Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use least_squares solver from ndarray-linalg #125

Merged
merged 6 commits into from
May 2, 2021
Merged

Use least_squares solver from ndarray-linalg #125

merged 6 commits into from
May 2, 2021

Conversation

janmarthedal
Copy link
Contributor

Use the least squares solver from ndarray-linalg instead of solving the normal equations explicitly.

Resolves #25

@codecov-commenter
Copy link

codecov-commenter commented Apr 25, 2021

Codecov Report

Merging #125 (92007f9) into master (ce8a815) will increase coverage by 0.02%.
The diff coverage is 77.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #125      +/-   ##
==========================================
+ Coverage   59.84%   59.86%   +0.01%     
==========================================
  Files          74       74              
  Lines        7006     7007       +1     
==========================================
+ Hits         4193     4195       +2     
+ Misses       2813     2812       -1     
Impacted Files Coverage Δ
algorithms/linfa-linear/src/ols.rs 74.76% <77.77%> (-0.24%) ⬇️
...rithms/linfa-trees/src/decision_trees/algorithm.rs 51.08% <0.00%> (-1.45%) ⬇️
algorithms/linfa-tsne/src/lib.rs 48.78% <0.00%> (-1.22%) ⬇️
algorithms/linfa-kernel/src/lib.rs 71.30% <0.00%> (ø)
algorithms/linfa-pls/src/pls_generic.rs 69.01% <0.00%> (+0.30%) ⬆️
...hms/linfa-preprocessing/src/count_vectorization.rs 78.09% <0.00%> (+0.63%) ⬆️
algorithms/linfa-hierarchical/src/lib.rs 50.00% <0.00%> (+0.74%) ⬆️
...ms/linfa-preprocessing/src/tf_idf_vectorization.rs 51.88% <0.00%> (+0.94%) ⬆️
algorithms/linfa-pls/src/utils.rs 90.00% <0.00%> (+2.19%) ⬆️
algorithms/linfa-linear/src/float.rs 16.66% <0.00%> (+5.55%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce8a815...92007f9. Read the comment docs.

.solve_into(rhs)
// It would be cleaner to use ndarray_linalg::LeastSquaresSvd::least_squares,
// but that is currently not possible since B = C is required
let X = X.to_owned();
Copy link
Member

Choose a reason for hiding this comment

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

can you accept a view representation as parameter and avoid the copy here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see how, since the types of the data containers for X and y are different (B and C respectively). In an upcoming version of ndarray-linalg this restriction has been lifted so we don't have to make an explicit copy here (rust-ndarray/ndarray-linalg#272).

Copy link
Member

Choose a reason for hiding this comment

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

the data is copied for the intercept branch anyways. I pushed a PR https://github.com/janmarthedal/linfa/pull/1 which adds the copy only for the branch without intercept computation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see, that makes sense. Thank you for helping out!

@bytesnake bytesnake merged commit 3dc9cb0 into rust-ml:master May 2, 2021
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.

Improve Linear Regression: Use ndarray-linalg's lstsq, improve names and follow conventions
3 participants