Align Input-Data for Machine Learning

9 vues (au cours des 30 derniers jours)
David Rieger
David Rieger le 8 Mar 2018
Here is a simplified example of my problem:
I have a (9x5) array
fn=[62,98,122,123,63;90,124,328,487,91;552,553,501,743,138;758,826,739,1323,850;1279,1328,1334,1505,1274;1312,1512,1579,1635,1312;1519,1617,1696,1751,1518;1899,1889,1822,1818,1902;1917,1974,1966,1974,1907]
and I want to align the elements in each row, so that I can use it as an Input Matrix for Machine Learning. The values in each column should correlate to a category of desired values (CategoryValues) with a specific bandwidth.
CategoryValues =[60,90,250,500,900,1300,1500,1700,2000];
bandwidth=100;
for ii=1:length(CategoryValues)
minVal(ii)=(CategoryValues(ii)-bandwidth);
maxVal(ii)=(CategoryValues(ii)+ bandwidth);
end
I tried to implement a Code, and it works only beyond row1 and row2 well:
for pp=1:5
clear f1_aligned
f1_aligned=zeros(length(fn),1);
f1=fn(:,pp)
for kk=1:9
if any(and((f1 >=minVal(kk) ), (f1 <=maxVal(kk))))
indices = find(and((f1 >=minVal(kk) ), (f1 <=maxVal(kk))));
[blbl, idx_rel]=min(abs(f1(indices)-ImportantModes(kk)));
idx_rel = indices(idx_rel);
f1_aligned(kk)=f1(idx_rel);
end
end
Aligned_fn_Matrix(:,pp)=f1_aligned;
end
The Problem is: when I have two values for example 98 and 124, then value 98 should be in the first row for category 60 and value 124 should be in the Second row for category 90. Where do I overlook the mistake in my code?
Thanks in advance David

Réponses (0)

Catégories

En savoir plus sur Statistics and Machine Learning Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by