문제

I implemented a text classification model using Keras.

Most of the datasets that I use are imbalanced. Therefore, I would like to use SMOTE to handle said imbalance.

I tried both on plain text, and once the text was vectorized, but I don't seem to be able to apply SMOTE on text data.

I use imblearn and received the following error:

Expected n_neighbors <= n_samples,  but n_samples = 3, n_neighbors = 6

How can I fix this error? And is SMOTE a good idea? If not, what other ways could I deal with class imbalance?

도움이 되었습니까?

해결책

First of all, to reassure you, SMOTE should work on text data. SMOTE will work on any data type as long as there is a way to compute the distance between data points.

Based on the error message you receive, it seems that it's an implementation issue (adding part of your code or how much data you have would greatly help).

As the error states, you have only 3 samples but the method requires at least 6. My guess is that something went wrong and you should have much more than 3 samples.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 datascience.stackexchange
scroll top