Sebelino / hypnoscorer

Automated sleep stage classifier using semi-supervised approach.
GNU General Public License v2.0
8 stars 3 forks source link

how to use dbn #3

Open lyzhangjm opened 8 years ago

lyzhangjm commented 8 years ago

Thanks for you help. Now, I want to use DBN to extract feature. how to do ? The following is wrong. score('load shhs | segment 3 | organize dbn| partition 0.45 | svm rbf | eval')

Sebelino commented 8 years ago

I haven't really implemented feature extraction using DBN, so you may want to add some code of your own for that. I use a DBN to extract meta-features from an existing feature space which I then use in hope of increasing the classification accuracy. If you are interested you can find the (still incomplete) details on page 23 of my thesis draft. The details are a little hairy since I also perform a form of feature selection, but it would basically look like this:

>> score('load 200002 | segment 3 | extract | organize dbn 20 3 | partition 3:1 | svm linear | eval')

If you'd like to incorporate regular feature extraction with DBN into the program, I can give a few pointers on where to look:

lyzhangjm commented 8 years ago

Thanks, score('load 200002 | segment 3 | extract | organize dbn 20 3 | partition 3:1 | svm linear | eval') is ok. But the classification accuracy is low too. ans = trainingset: [2428x1 LabeledFeaturevector] testingset: [809x1 LabeledFeaturevector] svm: [1x1 SVM] predictedset: [809x1 LabeledFeaturevector] accuracy: 0.6527 confusionmatrix: [5x5 double] confusionorder: [5x1 char] if I want to improve the classification accuracy , what should I to do? Increasing training samples ?

lyzhangjm commented 8 years ago

I modify your code to increase training samples.The classification accuracy, however, is very low. ans = trainingset: [4867x1 LabeledFeaturevector] testingset: [1622x1 LabeledFeaturevector] svm: [1x1 SVM] predictedset: [1622x1 LabeledFeaturevector] accuracy: 0.4877 confusionmatrix: [5x5 double] confusionorder: [5x1 char]

the changed code: function [record,eeg,labels] = readrecord(spec) % Reads the record specified by the supplied parameter. datadir = 'data/'; records = { 'slp01a/slp01a' 'shhs/shhs1-200001'
'shhs/shhs1-200002' 'shhs/shhs1-200003' % 'shhs/shhs1-200004' % 'shhs/shhs1-200005' % 'shhs/shhs1-200006' % 'shhs/shhs1-200007' % 'shhs/shhs1-200008' % 'shhs/shhs1-200009' % 'shhs/shhs1-200010' }; % TODO cache this data matches = strfind(records,spec); matchindices = find(cellfun(@(y)~isempty(y),matches)); record = records{1}; if length(matchindices) > 0 record = records{matchindices(1)}; else error(['Found no record that matches input "',spec,'".']) end cachepath = cachepath(record); if exist(cachepath) disp(['Reading ',cachepath,'...']) data = load(cachepath,'eeg','labels'); eeg = data.eeg; labels = data.labels; else % recordpath = [datadir,record]; eeg = []; labels = []; for i=2:length(matchindices) record = records{i}; recordpath = [datadir,record]; disp(['Reading ',recordpath,'...']) [eg,lbl] = readsignal(recordpath); if i == 2 eeg = eg; labels = lbl; else eeg.Graph = [eeg.Graph;eg.Graph ]; % 200001-200003 are used to train model labels = [labels;lbl]; end end disp(['Reading ',recordpath,'...']) % [eeg,labels] = readsignal(recordpath); save(cachepath,'eeg','labels'); end end

Maybe the seven features are not enough. I don't understand your code completely. Could you increase the feature space? The reference [8] of your thesis used 28 features. Could you expand the feature space ?

Sebelino commented 8 years ago

Yeah, the added meta-features generated from the DBN unfortunately do not increase the accuracy significantly. The whole research question of my thesis is about investigating if it does, and I concluded that it does not. Then again, I only tested this approach with a very specific DBN setup (a 7-20-3 layer topology), so my results are pretty inconclusive. Here are some things you could try to increase the accuracy:

For more ideas, have a look at my Discussion and Future work sections of my thesis. Please take my conclusions with a grain of salt though; I haven't even defended my thesis yet.

Sebelino commented 8 years ago

Yes, increasing the number of features would probably help as well. If you are interested in doing so, you'd probably want to edit lines 14-22 in Segment.m.