Feature Exraction in Matlab then importing into Weka -


i have captured data accelerometer x,y,z. doing activity recognition , have separated data sit,run,jump.

i windowing data , extracting features such mean, variance etc , saving features.txt file,then going import data weka software classified.

i looking on file structure imported weka not sure 1 correct use weka.

should features stored in 1 txt file or seperate?

do need own columns: mean_x mean_y mean_z var_x var_y var_z label? or setup have below?

example of weka:

   @relation datashimmer     @attribute x numeric  @attribute y numeric  @attribute z numeric  }@attribute class { sitmean, jumpmean ,  runmean, sitstd, jumpstd, runstd, sitvar, jumpvar, runvar, sitrange, jumprange, runrange   @data    9.0706440e+00   7.8577383e-01   2.4532359e+00   jumpmean    9.6451465e+00   7.8731349e-01   3.1504403e+00   jumpmean    8.1915240e+00   9.9549126e-01   2.4723417e+00   jumpmean    8.6773829e+00   6.3727150e-01   3.0240603e+00   jumpmean    8.6675553e+00   7.3380330e-01   3.0251476e+00   jumpmean    8.6544917e+00   8.4768398e-01   2.8385212e+00   jumpmean    9.5032030e+00   1.1324107e+00   2.1942181e+00   jumpmean    9.5477273e+00   1.0467068e+00   2.0262543e+00   runmean    9.5686235e+00   1.1320179e+00   1.8989209e+00   runmean    9.2875020e+00   8.6683897e-01   1.9064545e+00   runmean    9.3515172e+00   9.2082513e-01   2.2105460e+00   runmean    9.6041949e+00   9.2349286e-01   2.5863699e+00   runmean    9.6029677e+00   7.4794280e-01   2.3176337e+00   runmean    9.1105362e+00   9.0374931e-01   2.1625089e+00   runmean   -5.0683414e-01  -4.4845132e+00   8.8514156e+00  sitmean   -4.9025531e-01  -4.4989652e+00   8.8622800e+00  sitmean   -4.9871921e-01  -4.4879779e+00   8.8922710e+00  sitmean   -5.0798669e-01  -4.4828028e+00   8.8459366e+00  sitmean   -5.4927840e-01  -4.4699890e+00   8.8474149e+00  sitmean   -5.3211037e-01  -4.4591018e+00   8.8433826e+00  sitmean   -5.5223809e-01  -4.4869555e+00   8.8594771e+00  sitmean   -4.7530904e-01  -4.4812295e+00   8.8135292e+00  sitmean   -5.4696903e-01  -4.4788825e+00   8.8484514e+00  sitmean   -5.5149171e-01  -4.4587802e+00   8.8630469e+00  sitmean   -5.3465224e-01  -4.4478393e+00   8.8383810e+00  sitmean   -5.1742062e-01  -4.4637259e+00   8.8325696e+00  sitmean   -5.4154869e-01  -4.4833639e+00   8.8562804e+00  sitmean   -5.7514668e-01  -4.4912760e+00   8.8727185e+00  sitmean    9.3696539e+00   1.1837913e+00  -2.6525999e+00   jumpmean    8.6643644e+00   1.2731911e+00  -2.4803529e+00   jumpmean    8.0837365e+00   1.9774159e+00  -2.8276019e+00   jumpmean    8.0305034e+00   1.2057473e+00  -1.9911895e+00   jumpmean    7.9512264e+00   4.5797049e+00  -8.0403707e-01   jumpmean    8.5823014e+00   3.9339561e+00  -2.6684712e+00   jumpmean    8.2940896e+00   2.1376560e+00  -2.7870077e+00   jumpmean    9.4819739e+00   8.1379138e-01  -3.1084057e+00   runmean    9.0599416e+00   3.9622206e-01  -3.4679528e+00   runmean    9.3782963e+00   9.4021813e-01  -3.3614160e+00   runmean    9.4959636e+00   8.3451458e-01  -3.0700251e+00   runmean    9.3596252e+00   7.6187722e-01  -3.3890264e+00   runmean    9.4984387e+00   1.1694115e+00  -3.3733935e+00   runmean    8.9490648e+00   1.4501386e+00  -3.1231425e+00   runmean    8.3033044e+00  -8.7385271e-01   4.9949720e+00  sitmean    8.2657411e+00  -9.2072139e-01   5.0284777e+00  sitmean    8.2039554e+00  -9.1552295e-01   5.1517434e+00  sitmean    8.2272207e+00  -8.4401430e-01   5.1535285e+00  sitmean    8.2654827e+00  -7.9834045e-01   5.0608142e+00  sitmean    8.2999421e+00  -8.6703733e-01   5.0902732e+00  sitmean    8.2944043e+00  -8.0556494e-01   5.0225056e+00  sitmean    8.5033422e+00   3.0787253e+00   3.5076829e+00   jumpstd    7.6895407e+00   3.1243470e+00   3.0559549e+00   jumpstd    7.5029557e+00   4.0664196e+00   4.1725267e+00   jumpstd    7.5436436e+00   4.3278471e+00   3.8818316e+00   jumpstd    6.1032521e+00   4.6354434e+00   3.5036980e+00   jumpstd    7.4142339e+00   4.0956300e+00   3.7602181e+00   jumpstd    7.9337673e+00   3.2664252e+00   4.2575543e+00   jumpstd    5.0545343e+00   2.8901073e+00   3.5430258e+00   runstd    5.3394208e+00   2.1666505e+00   3.7298383e+00   runstd    4.8233755e+00   3.0923609e+00   3.4364285e+00   runstd    5.3904459e+00   2.6258827e+00   3.3256969e+00   runstd    4.3812033e+00   2.7708500e+00   2.5985276e+00   runstd    4.1402607e+00   4.0070005e+00   2.7039632e+00   runstd    4.2720294e+00   4.6312551e+00   4.4228231e+00   runstd    2.7539715e-01   2.3209201e-01   3.2587558e-01   sitstd    1.5065993e-01   1.7074749e-01   1.7440757e-01   sitstd    1.6740466e-01   1.5952978e-01   1.6872027e-01   sitstd    1.6208795e-01   1.6157018e-01   1.5045205e-01   sitstd    1.8287180e-01   1.7500556e-01   1.9729539e-01   sitstd    1.8928747e-01   1.9478179e-01   1.4550928e-01   sitstd    1.7755868e-01   1.7635119e-01   1.4697588e-01   sitstd 

my matlab code:

%windowparams fq = 51.2; %sample rate of shimmer windowlength = 2; %length each window in seconds startpos = 1; startpos2 = 1; startpos3 = 1; %starting position 1st win endpos = startpos + (windowlength * floor(fq)); endpos2 = startpos2 + (windowlength * floor(fq)); endpos3= startpos3 + (windowlength * floor(fq)); %end position 1st win totalwindows = floor(length(martysit)/fq/windowlength); totalwindows2 = floor(length(martyjump)/fq/windowlength); totalwindows3 = floor(length(martyrun)/fq/windowlength); stats = zeros(windowlength,9);  = 1:totalwindows     eprange = range(martysit(startpos:endpos,:));%calculate window range     martysitfeatures (i,1:3) = eprange; %x, y & z axis values each stat     %next window position     startpos = endpos+1;     endpos= startpos + (windowlength * floor(fq));     martysitfeatures (:,4) = 10; end = 1:totalwindows2     eprange = range(martyjump(startpos2:endpos2,:));     %calculate window range     %x, y & z axis values each stat     martyjumpfeatures (i,1:3) = eprange;     %next window position     startpos2 = endpos2+1;     endpos2 = startpos2+ (windowlength * floor(fq));     martyjumpfeatures (:,4) = 11; end  = 1:totalwindows3     eprange = range(martyrun(startpos3:endpos3,:));     %calculate window range     %x, y & z axis values each stat     martyrunfeatures (i,1:3) = eprange;     %next window position     startpos3 = endpos3+1;     endpos3 = startpos3+ (windowlength * floor(fq));     martyrunfeatures (:,4) = 12; end 

you can either import csv files or arff files. default format import data in weka being arff format.

the details arff format described here.

you can add following header:

@relation movement  @attribute x  numeric @attribute y  numeric @attribute z  numeric @attribute class        {sit,run,jump}  @data  [x array] [y array] [z array] [class array] 

if want add mean information attribute:

@relation movement  @attribute mean_x  numeric @attribute mean_y  numeric @attribute mean_z  numeric @attribute x  numeric @attribute y  numeric @attribute z  numeric @attribute class        {sit,run,jump}  @data  [mean_x array] [mean_y array] [mean_z array] [x array] [y array] [z array] [class array] 

then save txt file .arff extension.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -