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); }
public void getModelDescription(StringBuilder out, int indent) { for (int i = 0; i < tree.getModelContext().numOutputAttributes(); i++) { StringUtils.appendIndented(out, indent, " [" + tree.getModelContext().outputAttribute(i).name() + "]"); if (getModelContext() != null) { for (int j = 0; j < getModelContext().numOutputAttributes(); j++) { if (getModelContext().attribute(j).isNumeric()) { out.append((j == 0 || weights[i][j] < 0) ? " " : " + "); out.append(String.format("%.4f", weights[i][j])); out.append(" * "); out.append(getAttributeNameString(j)); } } out.append(" + " + weights[i][getModelContext().numOutputAttributes()]); } StringUtils.appendNewline(out); } } }