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

plugin in gqis2 for osx doesn't recognize scikit-learn #10

Open
knussear opened this issue Apr 9, 2018 · 13 comments
Open

plugin in gqis2 for osx doesn't recognize scikit-learn #10

knussear opened this issue Apr 9, 2018 · 13 comments

Comments

@knussear
Copy link

knussear commented Apr 9, 2018

Trying to run random forest for qgis2 on osx with your plugin. Says it needs scikit-learn. Following instructions with pip I get
Requirement already satisfied: scikit-learn in ./anaconda2/lib/python2.7/site-packages

Yet the plugin doesn't recognize the installation.

@nkarasiak
Copy link
Owner

I never tried it on OSX.
When you open QGIS, run the Python Console (https://docs.qgis.org/2.18/en/docs/user_manual/plugins/python_console.html) and enter :
import sklearn
Does this generate an error ?
If yes, scikit learn is not well installed.

@knussear
Copy link
Author

knussear commented Apr 10, 2018 via email

@nkarasiak
Copy link
Owner

Hello Ken,
Can you tell me what Qgis version are you using ?

Did this work when you use the sample dataset ?

I just upload a new version on Qgis repository (V2.5.3) which should be available to download asap.

PS : when you type :
import scipy
Did this generate an error ?

@knussear
Copy link
Author

knussear commented Apr 11, 2018 via email

@jnederend
Copy link

I'm getting a similar error on Windows 10. My setup is installed via osgeo4w.

  • QGIS 2.18.18 LTR (Python version stuck on 2.7.5)

  • Numpy v1.12.1+mkl-1

  • Scipy 0.19.0

  • scikit-learn v. 0.19.0 --> forced downgrade when installing via pip due to numpy limitation (latest scikit needs latest numpy)

I get the following error when testing the dzetsaka sample project.

Error loading result layer:
			Traceback (most recent call last):
			  File "C:/OSGEO4~1/apps/qgis-ltr/./python/plugins\processing\gui\Postprocessing.py", line 85, in handleAlgorithmResults
			    dataobjects.load(out.value, name, alg.crs,
			UnboundLocalError: local variable 'name' referenced before assignment

@nkarasiak
Copy link
Owner

If you tried with samples data and with RF/GMM algorithms and if it works, could you please send me a little sample of your data (shape/raster) to test it on my side ?
If I can reproduce this error it will be more helpful. (mail : nicart @ gmail dot com)

Just to know, how many bands have your raster ? Does it have an alpha band ? If yes, try with removing it.
Thanks.

@jnederend
Copy link

I successfully ran the sample data using RF and GMM from the plugin's panel. If I try to "train algorithm" from the processing toolbox, I get the above error on the sample data, and the same for my own data.

When I run my own data using the plugin's "perform the classification" button it immediately gives a python error:

Traceback (most recent call last):
			  File "C:/Users/Jacob/.qgis2/python/plugins\dzetsaka\dzetsaka.py", line 1114, in runMagic
			    temp.initPredict(inRaster,model,outRaster,inMask,confidenceMap,inClassifier)
			  File "C:/Users/Jacob/.qgis2/python/plugins\dzetsaka\scripts\mainfunction.py", line 314, in initPredict
			    predictedImage=self.predict_image(inRaster,outRaster,tree,inMask,confidenceMap,-10000,SCALE=[M,m],classifier=classifier)
			UnboundLocalError: local variable 'tree' referenced before assignment

My raster is singleband with no alpha band.

@nkarasiak
Copy link
Owner

nkarasiak commented Apr 17, 2018

I try with the sample dataset with just the first band and it goes well.
For the processing toolbox (with GMM), everything worked fine under Windows 7.

Traceback (most recent call last): File "C:/PROGRA~1/QGIS2~1.18/apps/qgis-ltr/./python/plugins\processing\gui\Postprocessing.py", line 85, in handleAlgorithmResults dataobjects.load(out.value, name, alg.crs, UnboundLocalError: local variable 'name' referenced before assignment

Only this error, but I need to desactivate loading model/confusion matrix after algorithm has run. Error is shown but everything worked.
RF/SVM/KNN are not optimized (and not planned) for raster with less than 3 bands.

@jnederend
Copy link

Ah I've made some rookie mistakes. I was attempting to run on temporary files to try to automate the process, and should not have chosen a non-GMM function for my NDVI rasters. The RF function works from the plugin panel using a locally-saved RGB composite.

If I train the algorithm from the processing toolbox, what should the file extension be for the model?

@nkarasiak
Copy link
Owner

nkarasiak commented Apr 17, 2018 via email

@SIGGIF
Copy link

SIGGIF commented Apr 24, 2018

Hello, I work on Windows 7 and I'm using QGIS 2.18.13, Python 3.7.
I would like to test the random forest method.
I'm sorry but I can't install scikit-learn, even if I try to do the pip installed on osgeo4w-setup-x86_64.exe (explain there https://github.com/lennepkade/dzetsaka/#installation-of-scikit-learn/) and even if I enter import sklearn on Python Console. I don't understand why ?
I always have the same error message when I run the classification :
image
Thank you for your help !

@nkarasiak
Copy link
Owner

Hello @SIGGIF ,
I just updated the how to install scikit-learn for Qgis 3.
You say you use Qgis 2.18.13 with Python 3.7. But Qgis 2 is on Python 2 and Qgis 3 on Python 3.
If you use Qgis 3, just check in OsGeo setup if you installed pip3, if so, just follow the howto process here : https://github.com/lennepkade/dzetsaka#installation-of-scikit-learn

@vidlb
Copy link

vidlb commented Mar 3, 2020

Most likely the same problem than #15, see my response

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

No branches or pull requests

5 participants