public int inputAttributeIndex(int index) { int ret = 0; if (classIndex == Integer.MAX_VALUE) {//Multi Label if(index<range.getStart())//JD ret= index; else ret= index+range.getSelectionLength(); } else { //Single Label ret = classIndex() > index ? index : index + 1; } return ret; }
/** * Sets the range from a string representation. * * @param range the start and end string * */ public void setRange(String range) { String single = range.trim(); int hyphenIndex = range.indexOf('-'); if (hyphenIndex > 0) { this.start = rangeSingle(range.substring(0, hyphenIndex)); this.end = rangeSingle(range.substring(hyphenIndex + 1)); } else { int number = rangeSingle(range); if (number >= 0) { // first n attributes this.start = 0; this.end = number; } else { // last n attributes this.start = this.upperLimit + number > 0 ? this.upperLimit + number : 0; this.end = this.upperLimit - 1; } } }
public void setUpper(int attributeNumber) { this.upperLimit = attributeNumber; this.setRange(this.rangeText); }
public InstanceAttributesSelector(InstancesHeader sourceInstances, int [] targetInputIndices, int [] targetOutputIndices){ this.targetInputIndices=targetInputIndices; this.targetOutputIndices=targetOutputIndices; this.numSourceInstancesOutputs=sourceInstances.numOutputAttributes(); int totAttributes=this.targetInputIndices.length+this.targetOutputIndices.length; targetInstances= new InstancesHeader(); List<Attribute> v = new ArrayList<Attribute>(totAttributes); List<Integer> indexValues = new ArrayList<Integer>(totAttributes); int ct=0; for (int i=0; i<this.targetInputIndices.length;i++) { v.add(sourceInstances.inputAttribute(this.targetInputIndices[i])); indexValues.add(ct); ct++; } for (int i=0; i<this.targetOutputIndices.length;i++) { v.add(sourceInstances.outputAttribute(this.targetOutputIndices[i])); indexValues.add(ct); ct++; } targetInstances.setAttributes(v,indexValues); Range r= new Range("-" + targetOutputIndices.length); r.setUpper(totAttributes); targetInstances.setRangeOutputIndices(r); }
public Range getRange() { return new Range(this.getValue()); }
public int outputAttributeIndex(int attributeIndex) { int ret = 0; if (classIndex == Integer.MAX_VALUE) {//Multi Label ret=attributeIndex+range.getStart(); //JD - Range should be a "block" } else { //Single Label ret = classIndex; } return ret; }
@Override protected Instance newDenseInstance(int numAttributes) { // numAttributes is this.instanceInformation.numAttributes() this.range.setUpper(numAttributes); return new DenseInstance(numAttributes); }
public int numOutputAttributes() { int ret = 0; if (classIndex == Integer.MAX_VALUE) {//Multi Label ret=range.getSelectionLength(); //JD } else { //Single Label ret = 1; } return ret; }
public InstanceOutputAttributesSelector(InstancesHeader sourceInstances, int [] targetOutputIndices){ this.targetOutputIndices=targetOutputIndices; this.numSourceInstancesOutputs=sourceInstances.numOutputAttributes(); int totAttributes=sourceInstances.numInputAttributes()+this.targetOutputIndices.length; targetInstances= new InstancesHeader(); List<Attribute> v = new ArrayList<Attribute>(totAttributes); List<Integer> indexValues = new ArrayList<Integer>(totAttributes); int numInputs=sourceInstances.numInputAttributes(); for (int i=0; i<numInputs;i++) { v.add(sourceInstances.inputAttribute(i)); indexValues.add(i); } for (int i=0; i<this.targetOutputIndices.length;i++) { v.add(sourceInstances.outputAttribute(this.targetOutputIndices[i])); indexValues.add(numInputs+i); } targetInstances.setAttributes(v,indexValues); Range r= new Range("-" + targetOutputIndices.length); r.setUpper(totAttributes); targetInstances.setRangeOutputIndices(r); }
Range r= new Range("start-end");
/** * Class index. * * @return the int */ @Override public int classIndex() { int classIndex = instanceHeader.classIndex(); // return ? classIndex : 0; if(classIndex == Integer.MAX_VALUE) if(this.instanceHeader.instanceInformation.range!=null) classIndex=instanceHeader.instanceInformation.range.getStart(); else classIndex=0; return classIndex; }
this.range.setUpper(numAttributes);
public int numInputAttributes() { int ret = 0; if (classIndex == Integer.MAX_VALUE) {//Multi Label ret=this.numAttributes()-range.getSelectionLength(); //JD } else { //Single Label ret = this.numAttributes() - 1; } return ret; }
Range r= new Range("start-end"); ds.setRangeOutputIndices(r); dataset=(new InstancesHeader(ds));