1 year ago
#329762
be_real
using SMOTE to treat imbalanced 3d array data
I have below data and here is the distribution of the classes.
X shape == (477324, 5, 11)
Y shape == (477324,)
{0: 11986, 1: 465338}
Since my dataset is imbalanced, I have tried RandomOverSampling using below code.
from imblearn.over_sampling import RandomOverSampler
oversample = RandomOverSampler(sampling_strategy='minority')
oversample.fit_resample(trainX[:,:,0], trainY)
Xo = trainX[oversample.sample_indices_]
yo = trainY[oversample.sample_indices_]
Xo shape == (930676, 5, 11).
yo shape == (930676,).
{0: 465338, 1: 465338}
However, how can I use SMOTE on the same instead of RandomOverSampler? I tried below code to apply SMOTE and reshaped it to 3d array as I need a 3d array after resampling too.
Xo_smote,yo_smote = oversample_Smote.fit_resample(trainX[:,:,0], trainY)
Xo shape == (930676, 5).
yo shape == (930676,).
org_shape= trainX.shape
Xo = np.reshape(Xo, org_shape)
and I get error "ValueError: cannot reshape array of size 51187180 into shape (477324,5,11)"
Any suggestions please.
python
multidimensional-array
imbalanced-data
smote
0 Answers
Your Answer