Christoph Budziszewski commited on 2009-04-07 15:54:26
Zeige 5 geänderte Dateien mit 23 Einfügungen und 30 Löschungen.
git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@173 83ab2cfd-5345-466c-8aeb-2b2739fb922d
... | ... |
@@ -135,8 +135,8 @@ switch task |
135 | 135 |
display('SOM'); |
136 | 136 |
disp('not implemented') |
137 | 137 |
|
138 |
- case 'X-SOM' |
|
139 |
- display('X-SOM'); |
|
138 |
+ case 'XSOM' |
|
139 |
+ display('XSOM'); |
|
140 | 140 |
somopts.size = [3 3]; |
141 | 141 |
somopts.lattice = 'rect'; |
142 | 142 |
decode = som_xsubject_performance(header,data,somopts); |
... | ... |
@@ -1,6 +1,21 @@ |
1 |
-function decode = som_decode(sD, sM, svm_validation_data,svm_validation_label) |
|
1 |
+function decode = som_decode(sM, svm_validation_data,svm_validation_label) |
|
2 | 2 |
% the number of hits in each map-unit. |
3 | 3 |
|
4 |
-sValD = som_data_struct(svm_validation_data,'label',num2str(svm_validation_label)); |
|
5 |
-h = som_hits(sM,sValD); |
|
4 |
+sValD = som_data_struct(svm_validation_data,'labels',num2str(svm_validation_label)); |
|
5 |
+% h = som_hits(sM,sValD); |
|
6 | 6 |
bmu = som_bmus(sM, sValD, 'best'); |
7 |
+ |
|
8 |
+correct = 0; |
|
9 |
+nElements = length(svm_validation_label); |
|
10 |
+nBMUs = length(bmu); |
|
11 |
+ |
|
12 |
+for i = 1:nBMUs |
|
13 |
+ if isnan(bmu(i)) |
|
14 |
+ nElements = nElements - 1; |
|
15 |
+ elseif ( cell2mat(sM.labels(bmu(i))) == cell2mat(sValD.labels(i)) ) |
|
16 |
+ correct = correct + 1; |
|
17 |
+ end |
|
18 |
+end |
|
19 |
+ |
|
20 |
+decode = correct/nElements*100; |
|
21 |
+end |
|
7 | 22 |
\ No newline at end of file |
... | ... |
@@ -3,15 +3,10 @@ function [sD sM] = som_train(svmlabel, svmdata, somOptions) |
3 | 3 |
som_size = somOptions.size; |
4 | 4 |
som_lattice = somOptions.lattice; |
5 | 5 |
|
6 |
-display('SOM TRAINING'); |
|
7 | 6 |
addpath 'somtoolbox2'; |
8 |
-sD = som_data_struct(svmdata,'label',num2str(svmlabel)); |
|
9 |
-assignin('base','sD',sD); |
|
10 |
-sM = som_make(sD,'msize', som_size,'lattice', som_lattice); |
|
7 |
+sD = som_data_struct(svmdata,'labels',num2str(svmlabel)); |
|
11 | 8 |
|
9 |
+sM = som_make(sD,'msize', som_size,'lattice', som_lattice); |
|
12 | 10 |
sM = som_autolabel(sM,sD,'vote'); |
13 | 11 |
|
14 |
-assignin('base','sD',sD); |
|
15 |
-assignin('base','sM',sM); |
|
16 |
-display('type ''figure'' before visualisation'); |
|
17 | 12 |
end |
18 | 13 |
\ No newline at end of file |
... | ... |
@@ -67,7 +67,7 @@ for timeIndex = 1:timeLineEnd-timeLineStart+1 |
67 | 67 |
|
68 | 68 |
[sD sM] = som_train(svm_train_label, svm_train_data, somOpts); |
69 | 69 |
|
70 |
- performance = som_decode(sD, sM, svm_validation_data,svm_validation_label); |
|
70 |
+ performance = som_decode(sM, svm_validation_data,svm_validation_label); |
|
71 | 71 |
|
72 | 72 |
cross_value = [cross_value performance]; |
73 | 73 |
end |
... | ... |
@@ -1,17 +0,0 @@ |
1 |
-function [sD sM] = train_som(svmlabel, svmdata, somOptions) |
|
2 |
- |
|
3 |
-som_size = somOptions.size; |
|
4 |
-som_lattice = somOptions.lattice; |
|
5 |
- |
|
6 |
-display('SOM TRAINING'); |
|
7 |
-addpath 'somtoolbox2'; |
|
8 |
-sD = som_data_struct(svmdata,'label',num2str(svmlabel)); |
|
9 |
-assignin('base','sD',sD); |
|
10 |
-sM = som_make(sD,'msize', som_size,'lattice', som_lattice); |
|
11 |
- |
|
12 |
-sM = som_autolabel(sM,sD,'vote'); |
|
13 |
- |
|
14 |
-assignin('base','sD',sD); |
|
15 |
-assignin('base','sM',sM); |
|
16 |
-display('type ''figure'' before visualisation'); |
|
17 |
-end |
|
18 | 0 |
\ No newline at end of file |
19 | 1 |