@Override protected Instance newDenseInstance(int numAttributes) { // numAttributes is this.instanceInformation.numAttributes() this.range.setUpper(numAttributes); return new DenseInstance(numAttributes); }
this.range.setUpper(numAttributes);
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 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); }
r.setUpper(totAttributes); ds.setRangeOutputIndices(r); dataset=(new InstancesHeader(ds));