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

add multi Y options to nipals #122

Merged
merged 4 commits into from
Apr 22, 2021
Merged

add multi Y options to nipals #122

merged 4 commits into from
Apr 22, 2021

Conversation

josoriom
Copy link
Member

No description provided.

@codecov
Copy link

codecov bot commented Apr 20, 2021

Codecov Report

Merging #122 (11f2be5) into master (9dd5708) will not change coverage.
The diff coverage is 66.66%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #122   +/-   ##
=======================================
  Coverage   66.47%   66.47%           
=======================================
  Files          32       32           
  Lines        3147     3147           
  Branches      453      453           
=======================================
  Hits         2092     2092           
  Misses        975      975           
  Partials       80       80           
Impacted Files Coverage Δ
src/dc/nipals.js 96.07% <66.66%> (ø)

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 9dd5708...11f2be5. Read the comment docs.

@lpatiny
Copy link
Member

lpatiny commented Apr 20, 2021

Could you add an explanation about why exactly you want this change ? I don't see difference between. before and after.

@josoriom
Copy link
Member Author

First I removed this part of the code that disables the possibility of an Y with more than one column.
https://github.com/mljs/matrix/blob/master/src/dc/nipals.js#L21-L24

error message for when the maximum number of iterations is reached
https://github.com/josoriom/matrix/blob/master/src/dc/nipals.js#L48-L50

the normalization of loadings as the source code
https://github.com/josoriom/matrix/blob/master/src/dc/nipals.js#L55
source code: https://github.com/jobo322/MetaboMate/blob/master/R/NIPALS_PLS_component.R#L51

and the testcase to compare the results of both codes:
https://github.com/josoriom/matrix/blob/master/src/__tests__/decompositions/nipals.test.js#L97-L124

Copy link
Member

@jwist jwist left a comment

Choose a reason for hiding this comment

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

it looks fine to me. The difference is now that we can use a responde vector of more than one dimension, i.e., with multiple columns

@@ -18,22 +18,15 @@ export default class nipals {
} else {
Y = WrapperMatrix2D.checkMatrix(Y);
}
if (!Y.isColumnVector() || Y.rows !== X.rows) {
Copy link
Member

Choose a reason for hiding this comment

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

I would leave the test, just adapt it so it works for multiple Y

@@ -18,22 +18,15 @@ export default class nipals {
} else {
Y = WrapperMatrix2D.checkMatrix(Y);
}
if (!Y.isColumnVector() || Y.rows !== X.rows) {
throw new Error('Y must be a column vector of length X.rows');
Copy link
Member

Choose a reason for hiding this comment

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

adapt the text of the error message as well to reflect the results of the new test

src/dc/nipals.js Outdated

if (Y) {
let p = X.transpose().mmul(t).div(t.transpose().mmul(t).get(0, 0));
p = p.div(p.norm());
Copy link
Member

Choose a reason for hiding this comment

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

I would leave the normalisation as before, I think this is wrong in the reference code

@lpatiny lpatiny merged commit 3f6aafa into mljs:master Apr 22, 2021
lpatiny added a commit that referenced this pull request Apr 23, 2021
lpatiny added a commit that referenced this pull request Apr 23, 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.

3 participants