-1
$\begingroup$

I am try to normalize my features with this code:

from sklearn.preprocessing import MinMaxScaler
scaler  = MinMaxScaler(feature_range=(0, 1))
X_normaliser= scaler.fit_transform(features_mfcc)
print(len(X_normaliser))

But I am getting this error:

could not broadcast input array from shape (13,160) into shape (13)

And the format of features_mfcc is:

[array([[-9.0505310e+02, -9.0509668e+02, -9.0453448e+02, ...,
        -9.0509668e+02, -9.0509668e+02, -9.0465082e+02],
       [ 6.1652310e-02,  0.0000000e+00,  7.9452515e-01, ...,
         0.0000000e+00,  0.0000000e+00,  6.3048005e-01],
       [ 6.1638385e-02,  0.0000000e+00,  7.9280442e-01, ...,
         0.0000000e+00,  0.0000000e+00,  6.3033760e-01],
       ...,
       [ 6.1193265e-02,  0.0000000e+00,  7.3878741e-01, ...,
         0.0000000e+00,  0.0000000e+00,  6.2578565e-01],
       [ 6.1096039e-02,  0.0000000e+00,  7.2723877e-01, ...,
         0.0000000e+00,  0.0000000e+00,  6.2479138e-01],
       [ 6.0989607e-02,  0.0000000e+00,  7.1469700e-01, ...,
         0.0000000e+00,  0.0000000e+00,  6.2370300e-01]], dtype=float32), array([[-9.0509668e+02, -9.0509668e+02, -9.0509668e+02, ...,
        -8.5759808e+02, -8.5833606e+02, -8.5879651e+02],
       [ 0.0000000e+00,  0.0000000e+00,  0.0000000e+00, ...,
         4.4959282e+01,  4.3793659e+01,  4.0313797e+01],
       [ 0.0000000e+00,  0.0000000e+00,  0.0000000e+00, ...,
         1.4145700e+01,  1.7536686e+01,  9.3698139e+00],
       ...,
       [ 0.0000000e+00,  0.0000000e+00,  0.0000000e+00, ...,
         1.4837956e+00,  1.4310437e+00,  6.0682583e+00],
       [ 0.0000000e+00,  0.0000000e+00,  0.0000000e+00, ...,
        -3.7497518e+00, -2.3724816e+00,  4.0706646e-01],
       [ 0.0000000e+00,  0.0000000e+00,  0.0000000e+00, ...,
        -2.3869281e+00, -1.9489181e+00, -1.6806124e+00]], dtype=float32), array([[-905.0967   , -905.0967   , -905.0967   , ..., -902.40015  ,
        -901.81915  , -900.8688   ],
       [   0.       ,    0.       ,    0.       , ...,    3.8109207,
           4.632819 ,    5.901035 ],
       [   0.       ,    0.       ,    0.       , ...,    3.803548 ,
           4.6260605,    5.6991043],
       ...,
       [   0.       ,    0.       ,    0.       , ...,    3.5749695,
           4.4136033,    3.6421943],
       [   0.       ,    0.       ,    0.       , ...,    3.5268202,
           4.368108 ,    3.6132731],
       [   0.       ,    0.       ,    0.       , ...,    3.4748278,
           4.318678 ,    3.6719213]], dtype=float32), array([[-9.0450629e+02, -9.0407922e+02, -9.0477014e+02, ...,
        -8.9970392e+02, -9.0248578e+02, -9.0419568e+02],
       [ 8.3469510e-01,  1.4383652e+00,  4.6172076e-01, ...,
         5.6700068e+00,  2.9931142e+00,  1.2736886e+00],
       [ 8.3379471e-01,  1.4369218e+00,  4.6155667e-01, ...,
         2.2444835e+00,  1.8527040e+00,  1.2720714e+00],
       ...,
       [ 8.0518466e-01,  1.3911897e+00,  4.5630401e-01, ...,
         4.0884919e+00,  3.0479903e+00,  1.2209207e+00],
       [ 7.9899836e-01,  1.3813030e+00,  4.5516133e-01, ...,
         3.1457639e+00,  2.3051815e+00,  1.2098712e+00],
       [ 7.9225874e-01,  1.3705225e+00,  4.5391160e-01, ...,
         2.5792625e+00,  1.9462540e+00,  1.1978207e+00]], dtype=float32), array([[-9.0509668e+02, -9.0509668e+02, -9.0468939e+02, ...,
        -9.0480646e+02, -9.0484973e+02, -9.0509668e+02],
       [ 0.0000000e+00,  0.0000000e+00,  5.7561249e-01, ...,
         4.1038188e-01,  3.4921879e-01,  0.0000000e+00],
       [ 0.0000000e+00,  0.0000000e+00,  5.7488233e-01, ...,
         4.1028821e-01,  3.4913990e-01,  0.0000000e+00],
       ...,
       [ 0.0000000e+00,  0.0000000e+00,  5.5182308e-01, ...,
         4.0732536e-01,  3.4661859e-01,  0.0000000e+00],
       [ 0.0000000e+00,  0.0000000e+00,  5.4684269e-01, ...,
         4.0667912e-01,  3.4606788e-01,  0.0000000e+00],
       [ 0.0000000e+00,  0.0000000e+00,  5.4140812e-01, ...,
         4.0596974e-01,  3.4546313e-01,  0.0000000e+00]], dtype=float32)]

Can someone help me here?

$\endgroup$
5
  • 2
    $\begingroup$ Please post a mcve along with complete error message etc. $\endgroup$
    – hendrik
    Mar 19, 2020 at 12:19
  • $\begingroup$ Your features_mfcc is three-dimensional (a list of 2d arrays); how exactly do you want the data scaled? $\endgroup$
    – Ben Reiniger
    Mar 19, 2020 at 14:16
  • $\begingroup$ in this format : $\endgroup$
    –  Trager
    Mar 19, 2020 at 17:25
  • $\begingroup$ array([[ 1., -1., 2.], [ 2., 0., 0.], [ 0., 1., -1.]]) $\endgroup$
    –  Trager
    Mar 19, 2020 at 17:26
  • $\begingroup$ That's a 2d array; how do you want your 3d data dealt with? Also, your example in the comment doesn't appear to be scaled in any meaningful way, so again: how do you want the data scaled? $\endgroup$
    – Ben Reiniger
    Jun 8, 2020 at 13:41

1 Answer 1

1
$\begingroup$

Your MFCCs are a time-series, 2d representation. scikit-learn transformers like StandardScaler only works with 1d data (plus one dimension for the individual samples). So you need to implement the standardization yourself. And then convert the data to 1d.

Or summarize the entire MFCC time series into a single vector. For example using mean/std.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.