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

SVR regression-based unmixing error #75

Closed surigugajy closed 1 year ago

surigugajy commented 1 year ago

I have tested the use of SVR regression unmixing on two computers with the same data. One is running successfully and the other has the following errors:

QGIS version: 3.26.3-Buenos Aires QGIS code revision: 65e4edfdada Qt version: 5.15.3 Python version: 3.9.5 GDAL version: 3.5.1 GEOS version: 3.10.3-CAPI-1.16.1 PROJ version: Rel. 9.1.0, September 1st, 2022 PDAL version: 2.4.3 (git-version: 6311a6) Algorithm started at: 2022-09-26T14:36:20 Algorithm 'Regression-based unmixing' starting… Input parameters: { 'allowWithinClassMixtures' : True, 'background' : 0, 'classProbabilities' : '', 'dataset' : 'C:/Users/DELL/AppData/Local/Temp/processing_kutciY/6e06c234cd6843fc84b17f61544ecf53/outputClassificationDataset.pkl', 'ensembleSize' : 10, 'includeEndmember' : True, 'mixingProbabilities' : '0.6, 0.4', 'n' : 1200, 'outputFraction' : 'F:/suri/2-1997-2000-610-SR-VI-GLCM-multiyear-SVR-FRACTION.tif', 'raster' : 'F:/suri/2_1997_2000_610_SR_VI_GLCM_median.tif', 'regressor' : "from sklearn.pipeline import make_pipeline\nfrom sklearn.model_selection import GridSearchCV\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.svm import SVR\n\nsvr = SVR()\nparam_grid = {'kernel': ['rbf'],\n 'epsilon': [0.1],\n 'gamma': [0.001, 0.01, 0.1, 1, 10, 100, 1000],\n 'C': [0.001, 0.01, 0.1, 1, 10, 100, 1000]}\ntunedSVR = GridSearchCV(cv=3, estimator=svr, scoring='neg_mean_absolute_error', param_grid=param_grid)\nregressor = make_pipeline(StandardScaler(), tunedSVR)", 'robustFusion' : False }

Create ensemble Traceback (most recent call last): File "C:\Users/DELL/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\site-packages\typeguard__init__.py", line 903, in wrapper retval = func(*args, kwargs) File "C:\Users/DELL/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\enmapboxprocessing\algorithm\fitregressoralgorithmbase.py", line 89, in processAlgorithm regressor.fit(dump.X, dump.y.ravel()) File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\sklearn\pipeline.py", line 382, in fit self._final_estimator.fit(Xt, y, fit_params_last_step) File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\sklearn\model_selection_search.py", line 875, in fit self._run_search(evaluate_candidates) File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\sklearn\model_selection_search.py", line 1379, in _run_search evaluate_candidates(ParameterGrid(self.param_grid)) File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\sklearn\model_selection_search.py", line 852, in evaluate_candidates _warn_or_raise_about_fit_failures(out, self.error_score) File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\sklearn\model_selection_validation.py", line 367, in _warn_or_raise_about_fit_failures raise ValueError(all_fits_failed_message) ValueError: All the 147 fits failed. It is very likely that your model is misconfigured. You can try to debug the error by setting error_score='raise'.

Below are more details about the failures:

147 fits failed with the following error: Traceback (most recent call last): File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\sklearn\model_selection_validation.py", line 686, in _fit_and_score estimator.fit(X_train, y_train, fit_params) File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\sklearn\svm_base.py", line 173, in fit X, y = self._validate_data( File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\sklearn\base.py", line 596, in _validate_data X, y = check_X_y(X, y, check_params) File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\sklearn\utils\validation.py", line 1074, in check_X_y X = check_array( File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\sklearn\utils\validation.py", line 899, in check_array _assert_all_finite( File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\sklearn\utils\validation.py", line 146, in _assert_all_finite raise ValueError(msg_err) ValueError: Input X contains NaN. SVR does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Execution failed after 2.53 seconds

Loading resulting layers Algorithm 'Regression-based unmixing' finished

janzandr commented 1 year ago

As the error message says, your data contains NaN values, which is a problem. ValueError: Input X contains NaN.