- Perform the following operation for data normalization:
minmax.normalize<-function(ds, scaler=NULL){
if(is.null(scaler)){
for(f in ds$xFeatures){
scaler[[f]]$minval<-min(ds$data[,f])
scaler[[f]]$maxval<-max(ds$data[,f])
ds$data[,f]<-(ds$data[,f]-scaler[[f]]$minval)/(scaler[[f]]$maxval-scaler[[f]]$minval)
}
ds$scaler<-scaler
} else
{
for(f in ds$xFeatures){
ds$data[,f]<-(ds$data[,f]-scaler[[f]]$minval)/(scaler[[f]]$maxval-scaler[[f]]$minval)
}
}
return(ds)
}
- The minmax.normalize function normalizes the data using min-max normalization. When the scaler variable is NULL, it performs normalization using the dataset provided, or normalizes using scaler values. The normalized data pair plot is shown in the following figure:
This figure shows min-max normalization bringing the values within bounds [0, 1] and it does not change the distribution and correlations between features.