How can I scale / normalize data written in text files ?

2 次查看(过去 30 天)
Please I have training data input text file and output file (Attached). I need to scale the data between (0 to 1) before using them as training data in data mining then after training I would get an equation needs to be descaled (bringing it back as original scale).
Many thanks

回答(1 个)

Star Strider
Star Strider 2015-11-29
编辑:Star Strider 2015-11-29
I used my own data rather than your text files because it is easier to test them.
I would do this:
d = randi([-99 99], 10, 1); % Create Data
extr = [min(d) max(d) max(d)-min(d)]; % Extremes & Ranges
fwd_tran = (d - -sign(extr(1))*extr(1))/extr(3); % Map To (0,1)
rev_tran = extr(3)*fwd_tran + -sign(extr(1))*extr(1); % Map To Original
I believe this will do what you want. It is easy to create anonymous functions from ‘fwd_tran’ and ‘rev_tran’ if you need to:
fwd_tran = @(x) (x - -sign(extr(1))*extr(1))/extr(3); % Map To (0,1)
rev_tran = @(x) extr(3)*x + -sign(extr(1))*extr(1); % Map To Original
Test1 = fwd_tran(d);
Test2 = rev_tran(Q1);
Be sure to import your data and assign ‘extr’ before you use the functions.
  8 个评论
ND
ND 2015-11-29
No sorry your answer is very close to what I need but in case of equation ( I explain that with the question) I do not know how can I treat the equation which I got it after training to the scaled data and put this equation in original scale?
Many thanks for all help
Star Strider
Star Strider 2015-11-29
My pleasure.
To put the results of your equation back into the form (essentialy the ‘space’) of your original ‘input.txt’ data, use my ‘rev_tran’ function.
Just be sure to use your original data to calculate my ‘extr’ vector before you do anything else, and keep ‘extr’ in your workspace.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Text Analytics Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by