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

mlpack - Python: LARS throws runtime error #3324

Closed
demoronator opened this issue Nov 28, 2022 · 5 comments
Closed

mlpack - Python: LARS throws runtime error #3324

demoronator opened this issue Nov 28, 2022 · 5 comments

Comments

@demoronator
Copy link

demoronator commented Nov 28, 2022

Issue description

Your environment

  • version of mlpack: mlpack Python 4.0.0.post1, 4.0.0, 3.4.2
  • operating system: Ubuntu 20.04.5 LTS

Steps to reproduce

Code:

train_x = [
    [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
    [0.5, 0.5, 0.5, 0.5, 0.5, 0.5],
    [1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
]
train_y_px = [0.0, 0.5, 1.0]
lars_px = mlpack.lars(input_=train_x, responses=train_y_px,
                      lambda1=0.1, lambda2=0.1,
                      verbose=True)

Result:

[FATAL] Number of responses must be equal to number of rows of X!

Expected behavior

The rows of X(input_) and responses are the same as three.
So it should return the dictionary without error.

Actual behavior

It throws a runtime error.

@rcurtin
Copy link
Member

rcurtin commented Nov 28, 2022

Indeed, your input looks reasonable and it should work. Out of curiosity, does the code succeed if you specify train_x in a transposed form? (Or train_y_px in a transposed form?)

@demoronator
Copy link
Author

demoronator commented Nov 29, 2022

I tried

train_y_px = [
    [0],
    [0.5],
    [1],
]

It also failed with the same error.

@rcurtin
Copy link
Member

rcurtin commented Dec 1, 2022

Thanks for the report. It took a while to dig into it, but I found that the LARS method (and specifically LARS) happens to have a bug with how it is handled in the Python bindings, and some other languages too. If you want to read the details, check out #3327.

Until that PR is merged and released, you can work around the bug by transposing your X data matrix, like this:

train_x = [
    [0.0, 0.5, 1.0],
    [0.0, 0.5, 1.0],
    [0.0, 0.5, 1.0],
    [0.0, 0.5, 1.0],
    [0.0, 0.5, 1.0],
    [0.0, 0.5, 1.0],
]

mlpack 4.0.1 will be released soon (next couple weeks?) with a fix.

Thanks so much again for the report, and if you find more issues in the future please do not hesitate to report them! 👍

@demoronator
Copy link
Author

Great. Thank you!

@rcurtin
Copy link
Member

rcurtin commented Dec 30, 2022

mlpack 4.0.1 is released now, so this should be solved. Thanks again for the report! 👍

@rcurtin rcurtin closed this as completed Dec 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants