@Override public Instance makeTrue(Instance intnc) { int part = r.nextInt(2); if (part == 0) { intnc.setValue(1, indexOfValue("normal", priceValues)); intnc.setValue(3, indexOfValue("high", amountValues)); } else { intnc.setValue(0, indexOfValue("brown", colorValues)); intnc.setValue(1, indexOfValue("veryLow", priceValues)); intnc.setValue(4, indexOfValue("high", deliveryDelayValues)); } intnc.setClassValue(indexOfValue("interested", classValues)); return intnc; }
@Override public Instance makeTrue(Instance intnc) { int part = r.nextInt(2); if (part == 0) { intnc.setValue(0, indexOfValue("black", colorValues)); intnc.setValue(2, indexOfValue("90", paymentValues)); intnc.setValue(4, indexOfValue("veryLow", deliveryDelayValues)); } else { intnc.setValue(0, indexOfValue("magenta", colorValues)); intnc.setValue(1, indexOfValue("high", priceValues)); intnc.setValue(4, indexOfValue("veryLow", deliveryDelayValues)); } intnc.setClassValue(Arrays.asList(classValues).indexOf("interested")); return intnc; } },
@Override public Instance makeTrue(Instance intnc) { int part = r.nextInt(2); if (part == 0) { intnc.setValue(0, indexOfValue("blue", colorValues)); intnc.setValue(2, indexOfValue("60", paymentValues)); intnc.setValue(3, indexOfValue("low", amountValues)); intnc.setValue(4, indexOfValue("normal", deliveryDelayValues)); } else { intnc.setValue(0, indexOfValue("cyan", colorValues)); intnc.setValue(3, indexOfValue("low", amountValues)); intnc.setValue(4, indexOfValue("normal", deliveryDelayValues)); } intnc.setClassValue(Arrays.asList(classValues).indexOf("interested")); return intnc; } }
@Override public Instance makeTrue(Instance intnc) { int part = r.nextInt(2); if (part == 0) { intnc.setValue(1, indexOfValue("veryLow", priceValues)); intnc.setValue(2, indexOfValue("0", paymentValues)); intnc.setValue(3, indexOfValue("high", amountValues)); } else { intnc.setValue(0, indexOfValue("red", colorValues)); intnc.setValue(1, indexOfValue("low", priceValues)); intnc.setValue(2, indexOfValue("30", paymentValues)); } intnc.setClassValue(Arrays.asList(classValues).indexOf("interested")); return intnc; } },
@Override public Instance makeTrue(Instance intnc) { intnc.setValue(1, indexOfValue("high", priceValues)); intnc.setValue(3, indexOfValue("veryHigh", amountValues)); intnc.setValue(4, indexOfValue("high", deliveryDelayValues)); intnc.setClassValue(Arrays.asList(classValues).indexOf("interested")); return intnc; } },
private void setClassValue(Instance instance, double valueAttribute) { instance.setValue(this.instanceInformation.classIndex(), valueAttribute); }
/** * Finds the closest point in the hyper rectangle to a given point. Change the * given point to this closest point by clipping of at all the dimensions to * be clipped of. If the point is inside the rectangle it stays unchanged. The * return value is true if the point was not changed, so the the return value * is true if the point was inside the rectangle. * * @param node The current KDTreeNode in whose hyperrectangle the closest * point is to be found. * @param x a point * @return true if the input point stayed unchanged. */ protected boolean clipToInsideHrect(KDTreeNode node, Instance x) { boolean inside = true; for (int i = 0; i < m_Instances.numAttributes(); i++) { // TODO treat nominals differently!?? if (x.value(i) < node.m_NodeRanges[i][MIN]) { x.setValue(i, node.m_NodeRanges[i][MIN]); inside = false; } else if (x.value(i) > node.m_NodeRanges[i][MAX]) { x.setValue(i, node.m_NodeRanges[i][MAX]); inside = false; } } return inside; }
@Override public InstanceExample nextInstance() { InstancesHeader header = getHeader(); Instance inst = new DenseInstance(header.numAttributes()); inst.setDataset(header); int selected = this.instanceRandom.nextInt(10); for (int i = 0; i < 7; i++) { if ((1 + (this.instanceRandom.nextInt(100))) <= this.noisePercentageOption.getValue()) { inst.setValue(i, originalInstances[selected][i] == 0 ? 1 : 0); } else { inst.setValue(i, originalInstances[selected][i]); } } if (!this.suppressIrrelevantAttributesOption.isSet()) { for (int i = 0; i < NUM_IRRELEVANT_ATTRIBUTES; i++) { inst.setValue(i + 7, this.instanceRandom.nextInt(2)); } } inst.setClassValue(selected); return new InstanceExample(inst); }
@Override public InstanceExample nextInstance() { InstancesHeader header = getHeader(); Instance inst = new DenseInstance(header.numAttributes()); inst.setDataset(header); int selected = this.instanceRandom.nextInt(10); for (int i = 0; i < 7; i++) { if ((1 + (this.instanceRandom.nextInt(100))) <= this.noisePercentageOption.getValue()) { inst.setValue(this.numberAttribute[i], originalInstances[selected][i] == 0 ? 1 : 0); } else { inst.setValue(this.numberAttribute[i], originalInstances[selected][i]); } } if (!this.suppressIrrelevantAttributesOption.isSet()) { for (int i = 0; i < NUM_IRRELEVANT_ATTRIBUTES; i++) { inst.setValue(this.numberAttribute[i + 7], this.instanceRandom.nextInt(2)); } } inst.setClassValue(selected); return new InstanceExample(inst); }
@Override public Instance sourceInstanceToTarget(Instance sourceInstance) { double [] attValues = new double[targetInstances.numAttributes()]; Instance newInstance=new InstanceImpl(sourceInstance.weight(),attValues); for (int i=0; i<this.targetInputIndices.length; i++){ newInstance.setValue(i, sourceInstance.valueInputAttribute(targetInputIndices[i])); } for (int i=0; i<this.targetOutputIndices.length; i++){ newInstance.setValue(i, sourceInstance.valueOutputAttribute(targetOutputIndices[i])); } newInstance.setDataset(targetInstances); return newInstance; }
public InstanceExample nextInstance() { this.numInstances++; InstancesHeader header = getHeader(); Instance inst = new DenseInstance(header.numAttributes()); inst.setDataset(header); double nextValue = this.nextValue(); if (this.notBinaryStreamOption.isSet()) { inst.setValue(0, nextValue); } else { inst.setValue(0, this.nextbinaryValue(nextValue)); } //Ground truth inst.setValue(1, this.getChange() ? 1 : 0); if (this.getChange() == true) { //this.clusterEvents.add(new ClusterEvent(this, this.numInstances, "Change", "Drift")); } inst.setValue(2, nextValue); return new InstanceExample(inst); }
@Override public Instance sourceInstanceToTarget(Instance sourceInstance) { double [] attValues = new double[targetInstances.numAttributes()]; Instance newInstance=new InstanceImpl(sourceInstance.weight(),attValues); int numInputs=this.targetInstances.numInputAttributes(); for (int i=0; i<numInputs; i++){ newInstance.setValue(i, sourceInstance.valueInputAttribute(i)); } for (int i=0; i<this.targetOutputIndices.length; i++){ newInstance.setValue(numInputs+i, sourceInstance.valueOutputAttribute(targetOutputIndices[i])); } newInstance.setDataset(targetInstances); return newInstance; }
private void setValue(Instance instance, int numAttribute, double value, boolean isNumber) { double valueAttribute; if (isNumber && this.instanceInformation.attribute(numAttribute).isNominal) { valueAttribute = this.instanceInformation.attribute(numAttribute).indexOfValue(Double.toString(value)); //System.out.println(value +"/"+valueAttribute+" "); } else { valueAttribute = value; //System.out.println(value +"/"+valueAttribute+" "); } if (this.instanceInformation.classIndex() == numAttribute) { instance.setClassValue(valueAttribute); //System.out.println(value +"<"+this.instanceInformation.classIndex()+">"); } else { instance.setValue(numAttribute, valueAttribute); } }
protected void setValue(Instance instance, int numAttribute, double value, boolean isNumber) { double valueAttribute; if (isNumber && this.instanceInformation.attribute(numAttribute).isNominal) { valueAttribute = this.instanceInformation.attribute(numAttribute).indexOfValue(Double.toString(value)); //System.out.println(value +"/"+valueAttribute+" "); } else { valueAttribute = value; //System.out.println(value +"/"+valueAttribute+" "); } if (this.instanceInformation.classIndex() == numAttribute) { setClassValue(instance, valueAttribute); //System.out.println(value +"<"+this.instanceInformation.classIndex()+">"); } else { //if(numAttribute>this.instanceInformation.classIndex()) // numAttribute--; instance.setValue(numAttribute, valueAttribute); } }
@Override public InstanceExample nextInstance() { Instance x = (Instance) ((Instance) this.inputStream.nextInstance().getData()); if(dataset==null){ System.out.println("INIT. "); initialize(x); } double z_[] = new double[dataset.numAttributes()]; Instance z = new InstanceImpl(x.weight(),z_); int d = x.numAttributes(); int h = numLatentOption.getValue(); int j_c = x.classIndex(); for(int k = 0; k < h; k++) { double sum_k = 0.; for(int j = 0; j < d; j++) { sum_k += (x.value(j) - c[k]); } double v = sum_k / Math.pow(r[k],2); z.setValue(k,Math.exp(-sum_k)); } z.setValue(h,x.classValue()); z.setDataset(dataset); return new InstanceExample(z); }
@Override public InstanceExample nextInstance() { double[] attVals = new double[this.numNominalsOption.getValue() + this.numNumericsOption.getValue()]; InstancesHeader header = getHeader(); Instance inst = new DenseInstance(header.numAttributes()); for (int i = 0; i < attVals.length; i++) { attVals[i] = i < this.numNominalsOption.getValue() ? this.instanceRandom.nextInt(this.numValsPerNominalOption.getValue()) : this.instanceRandom.nextDouble(); inst.setValue(i, attVals[i]); } inst.setDataset(header); inst.setClassValue(classifyInstance(this.treeRoot, attVals)); return new InstanceExample(inst); }
@Override public InstanceExample nextInstance() { double[] attVals = new double[this.numNominalsOption.getValue() + this.numNumericsOption.getValue()]; InstancesHeader header = getHeader(); Instance inst = new DenseInstance(header.numAttributes()); for (int i = 0; i < attVals.length; i++) { attVals[i] = i < this.numNominalsOption.getValue() ? this.instanceRandom.nextInt(this.numValsPerNominalOption.getValue()) : this.instanceRandom.nextDouble(); inst.setValue(i, attVals[i]); } inst.setDataset(header); inst.setClassValue(classifyInstance(this.treeRoot, attVals)); return new InstanceExample(inst); }
@Override public InstanceExample nextInstance() { double[] attVals = new double[this.numNominalsOption.getValue() + this.numNumericsOption.getValue()]; InstancesHeader header = getHeader(); Instance inst = new DenseInstance(header.numAttributes()); for (int i = 0; i < attVals.length; i++) { attVals[i] = i < this.numNominalsOption.getValue() ? this.instanceRandom.nextInt(this.numValsPerNominalOption.getValue()) : this.instanceRandom.nextDouble(); inst.setValue(i, attVals[i]); } inst.setDataset(header); inst.setClassValue(classifyInstance(this.treeRoot, attVals)); return new InstanceExample(inst); }
private Instance processInstance(Instance instance) { double [] attValues = new double[dataset.numAttributes()]; Instance newInstance=new InstanceImpl(instance.weight(),attValues); int count=0; for (int i=0; i<inputsSelected.numEntries(); i++){ int start=inputsSelected.getStart(i)-1; int end=inputsSelected.getEnd(i)-1; for (int j=start; j<=end; j++){ newInstance.setValue(count, instance.value(j)); count++; } } for (int i=0; i<outputsSelected.numEntries(); i++){ int start=outputsSelected.getStart(i)-1; int end=outputsSelected.getEnd(i)-1; for (int j=start; j<=end; j++){ newInstance.setValue(count, instance.value(j)); count++; } } newInstance.setDataset(dataset); return newInstance; }