notes

Personal notes
git clone git://git.laack.co/notes.git
Log | Files | Refs

MinMaxScaling.md (843B)


      1 # Min-max scaling 
      2 
      3 ML CH2
      4 
      5 **Definition:** Min-max scaling also referred to as normalization is a shift from the current values to between two arbitrary values. 
      6 
      7 These two bounds are normally either 0 and 1 or -1 and 1. It is optimal for neural networks to have zero mean inputs so a range from -1 to 1 is generally good.
      8 
      9 This is often done by subtracting the min value and then dividing by the difference between the min and the max. 
     10 
     11 Here is an example implementation:
     12 
     13 ```python
     14 
     15 # For each column (assuming they are numbers) iterate through them and set all
     16 # features to be equal to the (current - min) / diff. 
     17 # This has a lower bound of -1 and upper bound of 1.
     18 
     19 for i in df:
     20     min = df[i].min()
     21     diff = df[i].max() - min
     22     df[i] = (df[i] - min) / diff 
     23 
     24 df.describe()
     25 ```
     26 
     27 See [FeatureScaling](FeatureScaling.md) for more.