AlexanderFabisch / gmr

Gaussian Mixture Regression
https://alexanderfabisch.github.io/gmr/
BSD 3-Clause "New" or "Revised" License
168 stars 49 forks source link

ValueError: probabilities contain NaN #52

Closed xlzhu0317 closed 3 months ago

xlzhu0317 commented 4 months ago

Hi, I met an issue when i using my own data for training, the error message as follows, I also checked my data and confirmed that there was no NaN in the data: Traceback (most recent call last): File "C:/Users/FJL/Downloads/gmr-master/gmr-master/examples/Test2.py", line 43, in initial_means = kmeansplusplus_initialization(X_train, n_components, random_state) File "C:\Users\FJL\Downloads\gmr-master\gmr-master\gmr\gmm.py", line 46, in kmeansplusplus_initialization i = _select_next_center(X, centers, random_state, selected_centers, all_indices) File "C:\Users\FJL\Downloads\gmr-master\gmr-master\gmr\gmm.py", line 58, in _select_next_center return random_state.choice(all_indices, size=1, p=selection_probability)[0] File "mtrand.pyx", line 935, in numpy.random.mtrand.RandomState.choice ValueError: probabilities contain NaN

AlexanderFabisch commented 4 months ago

Hi @xlzhu0317 , thanks for reporting. To fix the issue, I have to reproduce the issue first. Could you generate a minimal example (data + code) to reproduce the issue?

xlzhu0317 commented 3 months ago

Thank you for your reply. I have attached my code and data as follow link: https://drive.google.com/file/d/1VM2QQ54O-jWdMd691BopnB0RXs6XoD2k/view?usp=drive_link

AlexanderFabisch commented 3 months ago

@xlzhu0317 I requested permission.

xlzhu0317 commented 3 months ago

sorry ,it's my mistake. I have approved your request.

AlexanderFabisch commented 3 months ago

Hi @xlzhu0317 ,

I just checked the data and script, but the data contains nans. You can easily confirm that by printing the pandas dataframe. I suspect this has to do with the pandas-excel interface. The quick fix is

data.dropna(inplace=True)

I will close this issue as it is not a problem with gmr. Don't hesitate to report any problems with the library though!