-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathVariable.java
More file actions
77 lines (55 loc) · 1.76 KB
/
Copy pathVariable.java
File metadata and controls
77 lines (55 loc) · 1.76 KB
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
70
71
72
73
74
75
76
77
import java.util.*;
import java.io.*;
public abstract class Variable {
String name ;
String value ;
int column ;
public Variable() {} ;
public Variable(String Name) {name = Name; value = null; }
void setValue(String val) { value = val ; }
String getValue() { return value; }
// used by categorical only
Vector labels ;
void setLabels(String Labels) {
labels = new Vector() ;
StringTokenizer tok = new StringTokenizer(Labels," ") ;
while (tok.hasMoreTokens())
labels.addElement(new String(tok.nextToken())) ;
}
// return the label with the specified index
String getLabel(int index) {
return (String)labels.elementAt(index);
}
// return a string containing all labels
String getLabels() {
String labelList = new String();
Enumeration enume = labels.elements() ;
while(enume.hasMoreElements())
labelList += enume.nextElement() + " " ;
return labelList ;
}
// given a label, return its index
int getIndex(String label) {
int i = 0, index = 0 ;
Enumeration enume = labels.elements() ;
while(enume.hasMoreElements()) {
if (label.equals(enume.nextElement()))
{ index = i ; break ; }
i++;
}
return i;
}
boolean categorical() {
if (labels != null) {
return true ;
} else {
return false ;
}
}
// used by the DataSet class
public void setColumn(int col) { column = col ; }
public abstract void computeStatistics(String inValue) ;
public abstract int normalize(String inValue, float[] outArray, int inx);
public int normalizedSize() { return 1 ; }
public String getDecodedValue(float[] act, int index) { return String.valueOf(act[index]); }
}