Home > Software design >  Normalize two arrays with second array the base for normalizing first array
Normalize two arrays with second array the base for normalizing first array

Time:10-29

In order to find the quality indicators like Generational Distance, Inverted Generational Distance, Epsilon Indicator, and HyperVolume for a Pareto front I want to normalize the values of approximation front obtained on solving the algorithm based on reference front which I assume encloses the approximation front.

reference_front = np.array([[0.5, 2.0], [1, 1.0], [1.2, 0.833], [2.3, 0.435], [3, 0.333]])
approximation_front = np.array([[0.8, 2.5], [1.0, 2.0], [2.1, 0.952], [2.8, 0.714]])
reference_point = [max(approximation_front[:,0]),max(approximation_front[:,0])]

I have used the code below for normalization. However, it is for one array at a time

from sklearn.preprocessing import MinMaxScaler
    min_max_scaler = MinMaxScaler()
reference_front_norm = min_max_scaler.fit_transform(reference_front)
approximation_front_norm = min_max_scaler.fit_transform(approximation_front)
reference_point = [max(approximation_front[:,0]),max(approximation_front[:,0])]

Here, approximation front and reference front are normalized separately. Can we normalize the approximate front between 0 to 1 based on max and min values of reference front.

CodePudding user response:

After applying fit_transform, you can simply use transform. This will use the 'fit' from the fit_transform call. In your case

reference_front_norm = min_max_scaler.fit_transform(reference_front)
approximation_front_norm = min_max_scaler.transform(approximation_front)
  • Related