[FEATURE-REQUEST] How to apply same MinMaxScaling to a set of columns? #1548
-
Description import pandas as pd
import vaex as vx
df = pd.DataFrame({'val1': [0.5, 1, 2],
'val2': [0.8, 1.2, 3.2],
'val3': [1.5, 1.9, 4.0]})
vdf = vx.from_pandas(df)
feat = [('val1', 'val2')] # assuming a tuple of columns would be understood as a set of columns to be grouped together.
scaler = vx.ml.MinMaxScaler(features=feat, prefix='scaled_')
scaler.fit(vdf)
scaler.transform(vdf)
# Min value is in 'val1' and max value is in 'val2'.
Out[32]:
# val1 val2 val3 scaled_val1 scaled_val2
0 0.5 0.8 1.5 0 0.11111
1 1 1.2 1.9 0.18518 0.259
2 2 3.2 4 0.55555 1 Thanks for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
What you describe is not how the MinMaxScaler is expected to work, but nothing stops you from doing this yourself. Find the min and the max of the features you are interested in, and you can just use the formula for MinMax scaling (you can look this up online). You could write your own function for this, something like
|
Beta Was this translation helpful? Give feedback.
-
Thanks @JovanVeljanoski, this is perfect! |
Beta Was this translation helpful? Give feedback.
What you describe is not how the MinMaxScaler is expected to work, but nothing stops you from doing this yourself.
Find the min and the max of the features you are interested in, and you can just use the formula for MinMax scaling (you can look this up online). You could write your own function for this, something like