MATLAB Answers

How can I normalize data between 0 and 1 ? I want to use logsig...

892 views (last 30 days)
Platon
Platon on 13 May 2013
Commented: Aviral Petwal on 22 Jun 2018
All is in the question: I want to use logsig as a transfer function for the hidden neurones so I have to normalize data between 0 and 1. The mapminmax function in NN tool box normalize data between -1 and 1 so it does not correspond to what I'm looking for.

Accepted Answer

José-Luis
José-Luis on 15 May 2013
bla = 100.*randn(1,10)
norm_data = (bla - min(bla)) / ( max(bla) - min(bla) )
  3 Comments
Aviral Petwal
Aviral Petwal on 22 Jun 2018
No need to denormalize the data. For your Test set also you can normalize the data with the same parameters and feed it to NN. If you trained on Normalised data just normalize your test set using same parameters and feed the data to NN.

Sign in to comment.

More Answers (3)

Jurgen
Jurgen on 15 May 2013
NDATA = mat2gray(DATA);
  2 Comments
Greg Heath
Greg Heath on 8 Oct 2016
Why not just try it and find out?
close all, clear all, clc
[ x1 , t1 ] = simplefit_dataset;
DATA1 = [ x1, t1 ];
DATA2 = [ x1; t1 ];
whos DATA1 DATA2
minmax1 = minmax(DATA1)
minmax2 = minmax(DATA2)
minmaxMTG1 = minmax( mat2gray(DATA1) )
minmaxMTG2 = minmax( mat2gray(DATA2) )
Hope this helps.
Greg

Sign in to comment.


Greg Heath
Greg Heath on 11 May 2017
Edited: Greg Heath on 11 May 2017
I like to calculate min, mean, std and max to detect outliers with standardized data (zero mean/unit variance). For normalization and denormalization I just let the training function use defaults
tansig and linear
however, if the ouput is naturally bounded use
tansig and tansig
or
tansig and logsig
In short, unless you are plotting you don't have to worry about anything except outliers.
Hope this helps.
Greg

Angus Steele
Angus Steele on 20 Sep 2017
function [ newValue ] = math_scale_values( originalValue, minOriginalRange, maxOriginalRange, minNewRange, maxNewRange )
% MATH_SCALE_VALUES
% Converts a value from one range into another
% (maxNewRange - minNewRange)(originalValue - minOriginalRange)
% y = ----------------------------------------------------------- + minNewRange
% (maxOriginalRange - minOriginalRange)
newValue = minNewRange + (((maxNewRange - minNewRange) * (originalValue - minOriginalRange))/(maxOriginalRange - minOriginalRange));
end

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!