Error in Predict Class Probability for SVC and Linear SVC

Issue #325 resolved
Agustin Lobo created an issue

In the case of SVC, the Predict Class Probability stops with error:

AttributeError: predict_proba is not available when probability=False

This is also the case if using the Classification Workflow, with a slightly different message:

Error: predict_proba is not available when probability=False

Comments (4)

  1. Fabian Thiel

    EDIT

    @Agustin Lobo Try setting the parameter probability=False to probability=True in the code section of Fit SVC, then it should work!

    svc = SVC(probability=True)
    

    @Andreas Janz I can reproduce this with the testdata:

    Also have a look at #326

    QGIS version: 3.10.0-A Coruña
    QGIS code revision: 6c816b4204
    Qt version: 5.11.2
    GDAL version: 2.4.1
    GEOS version: 3.8.0-CAPI-1.13.1 
    PROJ version: Rel. 5.2.0, September 15th, 2018
    Processing algorithm
    Algorithm 'Predict Class Probability' starting
    Input parameters:
    { 'classifier' : 'C:/Users/ThinkPad/AppData/Roaming/QGIS/QGIS3/profiles/default/processing/outputs/outEstimator.pkl', 'mask' : None, 'outFraction' : 'TEMPORARY_OUTPUT', 'raster' : 'C:/Users/ThinkPad/AppData/Roaming/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapboxtestdata/enmap_berlin.bsq' }
    
    start EstimatorPredictProbability, RasterSize(x=220, y=400)
    Traceback (most recent call last):
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\enmapboxgeoalgorithms\provider.py", line 151, in processAlgorithm
    result = self.processAlgorithm_()
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\enmapboxgeoalgorithms\algorithms.py", line 394, in processAlgorithm_
    estimator.predictProbability(filename=filename, raster=raster, mask=mask, progressBar=self._progressBar)
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\hubflow\core.py", line 5238, in _predictProbability
    applier.apply(operatorType=_EstimatorPredictProbability, raster=raster, estimator=self, mask=mask, mask2=mask2)
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\hubflow\core.py", line 48, in apply
    overwrite=self.kwargs.get('overwrite', True), *ufuncArgs, **ufuncKwargs)
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\hubdc\applier.py", line 976, in apply
    results = self._runProcessSubgrids()
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\hubdc\applier.py", line 1040, in _runProcessSubgrids
    blockResults.append(_Worker.processSubgrid(**kwargs))
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\hubdc\applier.py", line 1123, in processSubgrid
    nxblock=nx)
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\hubdc\applier.py", line 1269, in _apply
    blockResult = self.ufunc(*self._ufuncArgs, **self._ufuncKwargs)
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\hubflow\core.py", line 5336, in ufunc
    y = estimator.sklEstimator().predict_proba(X=X)
    File "C:\OSGEO4~1\apps\Python37\lib\site-packages\sklearn\utils\metaestimators.py", line 110, in __get__
    getattr(delegate, self.attribute_name)
    File "C:\OSGEO4~1\apps\Python37\lib\site-packages\sklearn\utils\metaestimators.py", line 110, in __get__
    getattr(delegate, self.attribute_name)
    File "C:\OSGEO4~1\apps\Python37\lib\site-packages\sklearn\svm\base.py", line 616, in predict_proba
    self._check_proba()
    File "C:\OSGEO4~1\apps\Python37\lib\site-packages\sklearn\svm\base.py", line 583, in _check_proba
    raise AttributeError("predict_proba is not available when "
    AttributeError: predict_proba is not available when probability=False
    
    Traceback (most recent call last):
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\enmapboxgeoalgorithms\provider.py", line 151, in processAlgorithm
    result = self.processAlgorithm_()
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\enmapboxgeoalgorithms\algorithms.py", line 394, in processAlgorithm_
    estimator.predictProbability(filename=filename, raster=raster, mask=mask, progressBar=self._progressBar)
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\hubflow\core.py", line 5238, in _predictProbability
    applier.apply(operatorType=_EstimatorPredictProbability, raster=raster, estimator=self, mask=mask, mask2=mask2)
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\hubflow\core.py", line 48, in apply
    overwrite=self.kwargs.get('overwrite', True), *ufuncArgs, **ufuncKwargs)
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\hubdc\applier.py", line 976, in apply
    results = self._runProcessSubgrids()
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\hubdc\applier.py", line 1040, in _runProcessSubgrids
    blockResults.append(_Worker.processSubgrid(**kwargs))
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\hubdc\applier.py", line 1123, in processSubgrid
    nxblock=nx)
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\hubdc\applier.py", line 1269, in _apply
    blockResult = self.ufunc(*self._ufuncArgs, **self._ufuncKwargs)
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\hubflow\core.py", line 5336, in ufunc
    y = estimator.sklEstimator().predict_proba(X=X)
    File "C:\OSGEO4~1\apps\Python37\lib\site-packages\sklearn\utils\metaestimators.py", line 110, in __get__
    getattr(delegate, self.attribute_name)
    File "C:\OSGEO4~1\apps\Python37\lib\site-packages\sklearn\utils\metaestimators.py", line 110, in __get__
    getattr(delegate, self.attribute_name)
    File "C:\OSGEO4~1\apps\Python37\lib\site-packages\sklearn\svm\base.py", line 616, in predict_proba
    self._check_proba()
    File "C:\OSGEO4~1\apps\Python37\lib\site-packages\sklearn\svm\base.py", line 583, in _check_proba
    raise AttributeError("predict_proba is not available when "
    AttributeError: predict_proba is not available when probability=False
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
    File "C:\Users\ThinkPad\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\enmapboxplugin\site-packages\enmapboxgeoalgorithms\provider.py", line 165, in processAlgorithm
    raise Exception('unexpected error')
    Exception: unexpected error
    
    Execution failed after 0.96 seconds
    
    Loading resulting layers
    Algorithm 'Predict Class Probability' finished
    

  2. Log in to comment