0

I am trying to use the imblearn random undersampler but I have the problem that my X_train is a 3D array and the undersampler needs a 2D array so I am getting the error:

Found array with dim 3. Estimator expected <= 2.

So I tried the solution described here: resampling data - using SMOTE from imblearn with 3D numpy arrays but that gives me the error "cannot reshape array of size 40000 into shape (160,10)".

Can someone help me how to change the arrays?

My arrays have the shape: y_train: (27704, 2) X_train: (27704, 30, 5)

Or does maybe someone know a better way how I could downsample my datasets?

Kirk1746
  • 23
  • 3
  • Use **np.transpose** to rearrange dimensions. Refer to this (https://stackoverflow.com/questions/32838802/numpy-with-python-convert-3d-array-to-2d) – Astrian_72954 Jul 24 '20 at 23:00
  • I have to admit that I already saw that but don't understand how. Especially not how I would get the 3D array back. – Kirk1746 Jul 24 '20 at 23:08
  • What's the significance of the dimensions in your arrays? And in the undersampler? You shoukd understand what your data is, and how it relates to solver. Don't blindly apply something you found on the net! – hpaulj Jul 25 '20 at 00:52
  • I know. Well, I think I know. My problem is that I have unbalanced data and need a way to downsample it so both classes are equally distributed. Imblearn is supposed to do exactly that. – Kirk1746 Jul 25 '20 at 00:55
  • To make things clearer why I need a 3d array in the first place: I am using an LSTM layer as input layer. The input to LSTMs is 3d with the form [samples, time steps, features] as far as I understand. I just want to balance my datasets first. – Kirk1746 Jul 25 '20 at 01:21

0 Answers0