From: Aaron A. <aa...@us...> - 2007-10-02 20:35:00
|
Update of /cvsroot/jboost/jboost/src/jboost/examples In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv2954/examples Modified Files: AttributeDescription.java ExampleDescription.java MultiDiscreteAttribute.java WeightDescription.java Log Message: Some misc small changes Index: ExampleDescription.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/examples/ExampleDescription.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ExampleDescription.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- ExampleDescription.java 2 Oct 2007 20:34:56 -0000 1.2 *************** *** 10,13 **** --- 10,34 ---- public class ExampleDescription { + /** An AttributeDescription for the labels */ + private LabelDescription label; + + /** An AttributeDescription for the example weights */ + private WeightDescription weight; + + /** a description of each attribute */ + private Vector attribute; + + /** the index of the example attribute that contains the label */ + private int m_labelIndex; + + /** the index of the example attribute that contains the weight */ + private int m_weightIndex; + + /** Flag for using private sampling weights */ + private boolean m_useSamplingWeights; + + + + /** * Defaul constructor *************** *** 147,168 **** - /** An AttributeDescription for the labels */ - private LabelDescription label; - - /** An AttributeDescription for the example weights */ - private WeightDescription weight; - - /** a description of each attribute */ - private Vector attribute; - - /** the index of the example attribute that contains the label */ - private int m_labelIndex; - - /** the index of the example attribute that contains the weight */ - private int m_weightIndex; - - /** Flag for using private sampling weights */ - private boolean m_useSamplingWeights; - - } --- 168,170 ---- Index: WeightDescription.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/examples/WeightDescription.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** WeightDescription.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- WeightDescription.java 2 Oct 2007 20:34:56 -0000 1.2 *************** *** 8,11 **** --- 8,13 ---- */ public class WeightDescription extends NumberDescription { + + public static final double MAX_WEIGHT = 1; WeightDescription(String name, Configuration config) *************** *** 25,29 **** public Attribute str2Att(String weight) throws BadAttException { double att = 1.0; // initialized because try complains otherwise. ! if (weight != null) { weight= weight.trim(); --- 27,31 ---- public Attribute str2Att(String weight) throws BadAttException { double att = 1.0; // initialized because try complains otherwise. ! if (weight != null) { weight= weight.trim(); *************** *** 35,42 **** } if (att < 0) { ! att= 0; } ! if (att > 1) { ! att= 1; } } --- 37,46 ---- } if (att < 0) { ! att= 0; ! throw new BadAttException("The weight: " + weight + " is less than 0",0,0); } ! if (att > MAX_WEIGHT) { ! att= MAX_WEIGHT; ! throw new BadAttException("The weight: " + weight + " is larger than MAX_WEIGHT=" + MAX_WEIGHT,0,0); } } Index: MultiDiscreteAttribute.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/examples/MultiDiscreteAttribute.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** MultiDiscreteAttribute.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- MultiDiscreteAttribute.java 2 Oct 2007 20:34:56 -0000 1.2 *************** *** 89,92 **** --- 89,107 ---- } + public int[] getValues() { + int[] ret = null; + if(values == null) { + ret = new int[1]; + ret[0] = value; + } else { + ret = new int[values.length]; + int j = 0; + for(int i=0; i<values.length; i++) + if (values[i]) + ret[j++] = i; + } + return ret; + } + public static void main(String[] args) { MultiDiscreteAttribute[] a = new MultiDiscreteAttribute[5]; Index: AttributeDescription.java =================================================================== RCS file: /cvsroot/jboost/jboost/src/jboost/examples/AttributeDescription.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** AttributeDescription.java 16 May 2007 04:06:02 -0000 1.1.1.1 --- AttributeDescription.java 2 Oct 2007 20:34:56 -0000 1.2 *************** *** 31,35 **** AttributeDescription retval=null; ! if (name.equals("labels")) retval=new LabelDescription(name,options,okValues); else if (name.equals(DataStream.WEIGHT_ATTR)) retval= new WeightDescription(name, options); else if(type.equals("number")) retval=new NumberDescription(name,options); --- 31,35 ---- AttributeDescription retval=null; ! if (name.equals(DataStream.LABELS_ATTR)) retval=new LabelDescription(name,options,okValues); else if (name.equals(DataStream.WEIGHT_ATTR)) retval= new WeightDescription(name, options); else if(type.equals("number")) retval=new NumberDescription(name,options); |