Christoph Budziszewski commited on 2009-03-09 13:28:44
Zeige 6 geänderte Dateien mit 0 Einfügungen und 61 Löschungen.
git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@146 83ab2cfd-5345-466c-8aeb-2b2739fb922d
... | ... |
@@ -1,38 +0,0 @@ |
1 |
-import java.util.HashMap; |
|
2 |
- |
|
3 |
-class LabelMap { |
|
4 |
- |
|
5 |
-private HashMap<String,Double> labelToValue; |
|
6 |
-private HashMap<Double,String> valueToLabel; |
|
7 |
- |
|
8 |
-public LabelMap(){ |
|
9 |
- this(2); |
|
10 |
-} |
|
11 |
- |
|
12 |
-public LabelMap(int numberOfLabels){ |
|
13 |
- labelToValue = new HashMap<String,Double>(numberOfLabels+1,1); |
|
14 |
- valueToLabel = new HashMap<Double,String>(numberOfLabels+1,1); |
|
15 |
-} |
|
16 |
- |
|
17 |
-public void add(String label, double value){ |
|
18 |
- labelToValue.put(label,value); |
|
19 |
- valueToLabel.put(value,label); |
|
20 |
-} |
|
21 |
- |
|
22 |
-public String getLabel(double value){ |
|
23 |
- return valueToLabel.get(value); |
|
24 |
-} |
|
25 |
- |
|
26 |
-public Double getValue(String label){ |
|
27 |
- return labelToValue.get(label); |
|
28 |
-} |
|
29 |
- |
|
30 |
-public String toString(){ |
|
31 |
- StringBuffer s = new StringBuffer("LabelMap: \n"); |
|
32 |
- for( String key : labelToValue.keySet()){ |
|
33 |
- s.append(key+'\t'+labelToValue.get(key)+"\n"); |
|
34 |
- } |
|
35 |
- return s.toString(); |
|
36 |
-} |
|
37 |
- |
|
38 |
-} |
|
39 | 0 |
\ No newline at end of file |
... | ... |
@@ -1,14 +0,0 @@ |
1 |
-function generateClassLabelValueMaps(filename) |
|
2 |
- |
|
3 |
-if exist(filename,'file') |
|
4 |
- vars = load(filename); |
|
5 |
- clMap = vars.classLabelMap; |
|
6 |
- nItems = size(clMap,1); |
|
7 |
- lm = LabelMap(nItems); |
|
8 |
- for item = 1:nItems |
|
9 |
- label = clMap(item,1); |
|
10 |
- value = cell2mat(clMap(item,2)); |
|
11 |
- lm.add(label,value) |
|
12 |
- end |
|
13 |
- assignin('base','lm',lm); |
|
14 |
-end |
|
15 | 0 |
\ No newline at end of file |