conifer icon indicating copy to clipboard operation
conifer copied to clipboard

sklearn_to_hls.py example issues

Open cgsavard opened this issue 4 years ago • 3 comments

I just downloaded the package and went to run the sklearn_to_hls.py in the example directory but ran into a few issues. To run, I did "python sklearn_to_hls.py". Here were the issues and my current solutions that you may want to consider including:

Error 1: import conifer ModuleNotFoundError: No module named 'conifer' Solution 1: Include init.py script in the top directory where the conifer directory is so that is can be seen as a package, then move the sklearn_to_hls.py script to the same top directory and run. There may be a better solution here, but in general the scripts in the examples directory cannot see the conifer directory and the conifer directory is not currently viewed as a package by python.

Error 2: y_hls = model.decision_function(X)[:,0] IndexError: too many indices for array Solution 2: y_hls is a 1D array so the [:,0] was the issue here. If you take this out then the issue is fixed. Every other script in example does not have [:,0] after model.decision_function so this is the only place where this will need to be fixed.

I can submit a pull request for my solution to error 2. For error 1, perhaps you have a better solution?

cgsavard avatar May 15 '20 00:05 cgsavard

Thanks for the comments, and the PR, I've merged it!

On Error 1, did you pip install . in the root directory of the project? That should make the package available to be imported everywhere. (I recommend pip install -e . if you will be editing the package files to make the changes available when you import)

thesps avatar May 18 '20 10:05 thesps

Yes, I used "python -m pip install ." to make sure it installed with my current python version (python 3.6.8). Then running "python examples/sklearn_to_hls.py" gives the same error "no module names conifer".

cgsavard avatar May 18 '20 19:05 cgsavard

I had the same issue. Using pip install -e . worked.

xu-jiachen avatar Jun 06 '20 16:06 xu-jiachen