EnMAP-Box / enmap-box

EnMAP-Box source code repository. See https://enmap-box.readthedocs.io for documentation
GNU General Public License v3.0
35 stars 16 forks source link

[Classification Workflow] Fit CatBoostClassifier not working #444

Open janzandr opened 1 year ago

janzandr commented 1 year ago
QGIS version: 3.30.0-'s-Hertogenbosch
QGIS code revision: f186b8efe0e
Qt version: 5.15.3
Python version: 3.9.5
GDAL version: 3.6.2
GEOS version: 3.11.1-CAPI-1.17.1
PROJ version: Rel. 9.1.1, December 1st, 2022
PDAL version: 2.4.3 (git-version: f8d673)
Algorithm started at: 2023-04-03T12:25:46
Algorithm 'Fit CatBoostClassifier' starting…
Input parameters:
{ 'classifier' : 'from catboost import CatBoostClassifier\nclassifier = CatBoostClassifier(n_estimators=100)', 'dataset' : 'C:/Users/Andreas/AppData/Local/Temp/processing_bNmWvU/4f505b6940b848dfaf42b236200df145/outputClassificationDataset.pkl', 'outputClassifier' : 'TEMPORARY_OUTPUT' }

Load training dataset: X=array[58, 177] y=array[58, 1] categories=['impervious', 'low vegetation', 'tree', 'soil', 'water']
Fit classifier
Traceback (most recent call last):
File "C:\Users\Andreas\AppData\Roaming\Python\Python39\site-packages\typeguard\__init__.py", line 1033, in wrapper
retval = func(*args, **kwargs)
File "C:\Users/Andreas/AppData/Roaming/QGIS/QGIS3\profiles\EnMAP-Box Develop/python/plugins\enmapboxplugin\enmapboxprocessing\algorithm\fitclassifieralgorithmbase.py", line 98, in processAlgorithm
classifier.fit(dump.X, dump.y.ravel())
File "C:\QGIS\apps\Python39\lib\site-packages\catboost\core.py", line 4768, in fit
self._fit(X, y, cat_features, text_features, embedding_features, None, sample_weight, None, None, None, None, baseline, use_best_model,
File "C:\QGIS\apps\Python39\lib\site-packages\catboost\core.py", line 2087, in _fit
with log_fixup(log_cout, log_cerr), \
File "C:\QGIS\apps\Python39\lib\contextlib.py", line 117, in __enter__
return next(self.gen)
File "C:\QGIS\apps\Python39\lib\site-packages\catboost\core.py", line 121, in log_fixup
_set_logger(_get_stream_like_object(log_cout), _get_stream_like_object(log_cerr))
File "C:\QGIS\apps\Python39\lib\site-packages\catboost\core.py", line 114, in _get_stream_like_object
raise CatBoostError(
_catboost.CatBoostError: Expected callable object or stream-like object

Execution failed after 0.12 seconds

Loading resulting layers
Algorithm 'Fit CatBoostClassifier' finished
janzandr commented 1 year ago

Can't reproduce the error in PyCharm. Only occurs in QGIS. Seams to be a None-EnMAP-Box issue, because it can be reproduced with Scikit-Learn only code: image