Update of /cvsroot/jboost/jboost/src/jboost/examples
In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv2628/src/jboost/examples
Modified Files:
ExampleSet.java Example.java
Log Message:
Visualizing fluctuations.
Index: Example.java
===================================================================
RCS file: /cvsroot/jboost/jboost/src/jboost/examples/Example.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Example.java 16 May 2007 04:06:02 -0000 1.1.1.1
--- Example.java 11 Sep 2008 21:25:45 -0000 1.2
***************
*** 83,86 ****
--- 83,90 ----
}
+ public ExampleDescription getDescription() {
+ return m_exampleDescription;
+ }
+
public String toString() {
return "instance=" + m_instance.toString(m_exampleDescription)
Index: ExampleSet.java
===================================================================
RCS file: /cvsroot/jboost/jboost/src/jboost/examples/ExampleSet.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ExampleSet.java 18 Sep 2007 03:25:59 -0000 1.2
--- ExampleSet.java 11 Sep 2008 21:25:45 -0000 1.3
***************
*** 19,22 ****
--- 19,24 ----
* The content of the ExampleSet */
private Example[] exampleSet;
+ public final String IndexName="INDEX"; // Indicates that a field is just an index, use to track individual examples in the log files.
+ private int indexLocation=-1; // The number of the attribute that stores the index.
/**
***************
*** 58,62 ****
--- 60,75 ----
}
isBinary = (noOfLabels==2 && !multiLabel);
+
+ // Find out if there is an attribute whose name is IndexName. This attribute is used to relate examples in different datasets.
+ for(int i=0; i<exampleDescription.getNoOfAttributes(); i++) {
+ String name = exampleDescription.getAttributeDescription(i).getAttributeName();
+ if(name.equals(IndexName)) {
+ indexLocation=i;
+ break;
+ }
+ System.out.printf("ExampleSet.indexLocation=%d%n", indexLocation);
+ }
}
+
/** add an example */
public void addExample(int index, Example example) {
***************
*** 76,79 ****
--- 89,97 ----
}
+ /** get the description of the fields in an example */
+ public ExampleDescription getExampleDescription() {
+ return exampleDescription;
+ }
+
/** get no of examples */
public int getExampleNo() {
***************
*** 270,273 ****
--- 288,305 ----
return s;
}
+
+ /** check if there is an attribute whose name is "INDEX" **/
+ public boolean hasIndex() {
+ return indexLocation>-1;
+ }
+
+ /** generate the list of example Indexes **/
+ public double[] getIndexes() {
+ double[] indexes = new double[exampleSet.length];
+ for(int i=0; i<indexes.length; i++) {
+ indexes[i]=((RealAttribute) exampleSet[i].getAttribute(indexLocation)).getValue();
+ }
+ return indexes;
+ }
}
|