My favorites
▼
|
Sign in
shapelogic
Declarative programming, image processing and vision toolkit
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
src
/
main
/
java
/
org
/
shapelogic
/
machinelearning
/
ConfidenceArraySelector.java
r1190
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package org.shapelogic.machinelearning;
import java.util.List;
import org.shapelogic.calculation.Calc1;
import org.shapelogic.util.Constants;
/** ConfidenceArraySelector takes a double[] and creates a String.<br />
*
* Translates a double[] that could come from a neural network to either the
* number of the one that is winning walue if any is or to a name for that.<br />
*
* @author Sami Badawi
*
*/
public class ConfidenceArraySelector
implements Calc1<double[], String>
{
public static final double DEFAULT_LIMIT = 0.5;
/** Parallel to the NumberedStream. */
protected List<String> _ohNames;
protected double _limit = DEFAULT_LIMIT;
/** Use the ohName to also be the name of the input stream. <br />
*
* @param ohNames
* @param limit
*/
public ConfidenceArraySelector(List<String> ohNames, double limit) {
_ohNames = ohNames;
_limit = limit;
}
/** Use the ohName to also be the name of the input stream. <br />
*
* @param ohNames
*/
public ConfidenceArraySelector(List<String> ohNames) {
this(ohNames, DEFAULT_LIMIT);
}
@Override
public String invoke(double[] input) {
int countOK = 0;
int lastFound = -1;
for (int i = 0; i < input.length; i++) {
if (_limit < input[i]) {
countOK++;
lastFound = i;
}
}
if (countOK == 1) {
if (_ohNames != null && lastFound < _ohNames.size() )
return _ohNames.get(lastFound);
else
return "" + lastFound;
}
return Constants.NO_OH;
}
public void setOhNames(List<String> ohNames) {
_ohNames = ohNames;
}
public List<String> getOhNames() {
return _ohNames;
}
}
Show details
Hide details
Change log
r992
by sami.badawi on Jan 2, 2009
Diff
ConfidenceArraySelector takes a double[] and creates a String.
Go to:
...ing/ConfidenceArraySelector.java
Project members,
sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 1770 bytes, 69 lines
View raw file
Powered by
Google Project Hosting