YttriLab / A-SOID

An active learning platform for expert-guided, data efficient discovery of behavior.
Other
55 stars 7 forks source link

Active Learning step: ValueError: Input X contains NaN #10

Closed topohl closed 1 year ago

topohl commented 1 year ago

Hey, when training a classifier with active learning I get the following error:

ValueError: Input X contains NaN. RandomForestClassifier 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

The annotation was exported using Boris and tracking data was generated using sleap. The config.ini looks as follows: config.ini.txt

I would appreciate your help greatly and many thanks already!

JensBlack commented 1 year ago

Hi,

Thanks for using A-SOiD. Can you please post the entire error message and describe at what step precisely this happened? Did it happen right at the beginning of that step or after a few steps?

The most likely scenario is that the NaN comes from pose estimation, but we are cleaning the file during import. Did you alter the data.sav file in any way?

The annotation file could also contain NaN values, but it's less likely. So if you can, could you verify whether the original CSV file contains any NaN?

topohl commented 1 year ago

Thank you for getting back this quickly,

I'm encountering the issue right when selecting "Classify" in the active learning tab.

The error message that is popping up is the following:

Traceback: File "C:\Users\topohl\Anaconda3\envs\asoid\lib\site-packages\streamlit\scriptrunner\script_runner.py", line 557, in _run_script exec(code, module.dict) File "C:\Users\topohl\Anaconda3\envs\asoid\lib\site-packages\asoid\app.py", line 332, in main() File "C:\Users\topohl\Anaconda3\envs\asoid\lib\site-packages\asoid\app.py", line 328, in main application_function() File "C:\Users\topohl\Anaconda3\envs\asoid\lib\site-packages\asoid\apps\C_auto_active_learning.py", line 136, in main rf_classifier.main() File "C:\Users\topohl\Anaconda3\envs\asoid\lib\site-packages\asoid\utils\auto_active_learning.py", line 536, in main self.base_classification() File "C:\Users\topohl\Anaconda3\envs\asoid\lib\site-packages\asoid\utils\auto_active_learning.py", line 315, in base_classification self.subsampled_classify() File "C:\Users\topohl\Anaconda3\envs\asoid\lib\site-packages\asoid\utils\auto_active_learning.py", line 190, in subsampled_classify self.all_model.fit(X_all_train, Y_all_train) File "C:\Users\topohl\Anaconda3\envs\asoid\lib\site-packages\sklearn\ensemble_forest.py", line 331, in fit X, y = self._validate_data( File "C:\Users\topohl\Anaconda3\envs\asoid\lib\site-packages\sklearn\base.py", line 596, in _validate_data X, y = check_X_y(X, y, **check_params) File "C:\Users\topohl\Anaconda3\envs\asoid\lib\site-packages\sklearn\utils\validation.py", line 1074, in check_X_y X = check_array( File "C:\Users\topohl\Anaconda3\envs\asoid\lib\site-packages\sklearn\utils\validation.py", line 899, in check_array _assert_all_finite( File "C:\Users\topohl\Anaconda3\envs\asoid\lib\site-packages\sklearn\utils\validation.py", line 146, in _assert_all_finite raise ValueError(msg_err)

I've added the more extensive console information:

console.txt

I did not alter the data.sav file and also checked the annotation file for NaN.

All the best, Tobias

JensBlack commented 1 year ago

I am at a conference this week but will get back to you ASAP. In the mean time, I recommend updating to the newest version of ASOID and checking whether the error still exists. There is an explanation in the readme on how to update A-SOID.

topohl commented 1 year ago

Thanks! I updated asoid to 0.2.1 now, the error, however still occurs (also on 0.1.0 and 0.2.0). All the best for the conference!