lasso-net / lassonet

Feature selection in neural networks
MIT License
207 stars 52 forks source link

An error when trying to run 'Usage' code in Readme #23

Closed Wei-weiWang closed 2 years ago

Wei-weiWang commented 2 years ago

Hi,

I tried to run the code in 'Usage'. However, I encounter this error:

from lassonet import LassoNetClassifierCV Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.7/dist-packages/lassonet/init.py", line 4, in from .interfaces import ( File "", line 1 (current_lambda=) ^ SyntaxError: invalid syntax

Could you please tell me why it's like this?

louisabraham commented 2 years ago

I am unable to reproduce your bug. What is your version of python?

Wei-weiWang commented 2 years ago

python 3.9

louisabraham commented 2 years ago

Oh it's because the CV isn't yet pushed to PyPI. I am going to fix a few other bugs and update the PyPI version.

Wei-weiWang commented 2 years ago

Thank you very much!

louisabraham commented 2 years ago

Can you test again? run pip install -U lassonet first

Wei-weiWang commented 2 years ago

Still has this error. Sorry, my python version is 3.7.

louisabraham commented 2 years ago

What version of lassonet are you installing?

Wei-weiWang commented 2 years ago

lassonet-0.0.9

molimi commented 2 years ago

I try it successfully, the interface.py in lassonet reports an error here, just remove the equal sign. The code snippet is as follows: if is_dense and self.model.selected_count() < X.shape[1]: is_dense = False if current_lambda / lambda_start < 2: warnings.warn( f"lambda_start={self.lambda_start:.3f} " "might be too large.\n" f"Features start to disappear at {current_lambda=:.3f}." ) # Here is an error, just remove the equal sign

louisabraham commented 2 years ago

Oh that's python 3.8 https://docs.python.org/3/whatsnew/3.8.html#f-strings-support-for-self-documenting-expressions-and-debugging

louisabraham commented 2 years ago

@Wei-weiWang just upgrade to python 3.8

molimi commented 2 years ago

@louisabraham good job,you can add a runtime environment, Python Version >= 3.8, Torch Version >= 1.11

louisabraham commented 2 years ago

Thanks!

I just edited the requirements (https://github.com/lasso-net/lassonet/commit/ac50fae68e932a3ec11fce010148c21a3e54c8ff)

Why should torch be >= 1.11 ?

molimi commented 2 years ago

If Torch Version < 1.11, the following error will be reported:

AttributeError: module 'torch' has no attribute 'scatter_reduce'

louisabraham commented 2 years ago

Indeed, thanks!