Normalizing values, what am I missing?

Asked

Viewed 190 times

1

R s are matrices of the type

[120.0, 77.34999999999998, 12.639999999999974, 39.270000000000074, 62.879999999999846, 54.549999999999656, 2.400000000000313, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 70.0, 70.0, 0.0, 0.0, 0.0, 62.879999999999846, 54.549999999999656, 2.400000000000313, 50.0, 0.0, 0.0, 0.0, 7.349999999999995, 12.639999999999974, 39.270000000000074, 62.879999999999846, 54.549999999999656, 2.400000000000313, 50.0, 50.0, 50.0, 50.0, 50.0, 0.0, 0.0]

i with this command create a new matrix formed with the maximum values of the matrices R...

input: matriz=np.array([[R], [R1], [R2], [R3], [R4], [R5], [R6]])
       Probabilidades=np.max(matriz, axis=0)
output:[[150.    77.35  12.64  39.27  62.88  54.55   2.4   50.    50.    50.
   50.    50.    50.    50.    70.    70.     0.     0.     0.    62.88
   54.55   2.4   50.     0.     0.     0.     7.35  12.64  89.27  62.88
   54.55   2.4   50.    50.    50.    50.    50.     0.    50.  ]]

I now want to normalize/Shut this, so that the maximum value is 100 (or 1) and not 150.

input: from sklearn import preprocessing
       import numpy as np

       matriz=np.array([[R], [R1], [R2], [R3], [R4], [R5], [R6]])
       Probabilidades=np.max(matriz, axis=0)
       matriz1 = preprocessing.MinMaxScaler()
       ProbNormalizada= matriz1.fit_transform(Probabilidades)
       print(ProbNormalizada)
  • Quano has in: matrix=np.array([[R], [R1], [R2], [R3], [R4], [R5], [R6]]), R s are matrices of type

  • [120.0, 77.34999999999998, 12.639999999999974, 39.270000000000074, 62.879999999999846, 54.549999999999656, 2.40000000313, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 70.0, 70.0, 0.0, 0.0, 62.879999999846, 54.549999999656, 2.40000000313, 50.0, 0.0, 0.0, 0.0, 7.349999999999995, 12.639999999999974, 39.270000000000074, 62.879999999999999846, 54.549999999999656, 2.400000000000313, 50.0, 50.0, 50.0, 50.0, 50.0, 0.0, 0.0]

  • and I with the command want a new matrix formed with the maximum values of the matrices R...

1 answer

1

I’m not sure if the term for what you want is "normalize" by the terms used in the sklearn I believe the most appropriate term would be scale (or something similar), see the example:

import numpy as np
from sklearn.preprocessing import minmax_scale

output = np.array([150.0, 77.35, 12.64, 39.27, 62.88, 54.55, 2.4, 50., 50., 50., 
                   50., 50., 50., 50., 70., 70., 0., 0., 0., 62.88, 54.55, 2.4,
                   50., 0., 0., 0., 7.35, 12.64, 89.27, 62.88, 54.55, 2.4, 50.,
                   50., 50., 50., 50., 0., 50.])    

output2 = minmax_scale(output.reshape(-1, 1)).reshape(len(output))
print(output2)

Exit:

[1.         0.51566667 0.08426667 0.2618     0.4192     0.36366667
 0.016      0.33333333 0.33333333 0.33333333 0.33333333 0.33333333
 0.33333333 0.33333333 0.46666667 0.46666667 0.         0.
 0.         0.4192     0.36366667 0.016      0.33333333 0.
 0.         0.         0.049      0.08426667 0.59513333 0.4192
 0.36366667 0.016      0.33333333 0.33333333 0.33333333 0.33333333
 0.33333333 0.         0.33333333]

If you want to know how the calculations are made see this link.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.