protected Instance newSparseInstance(double d) { Instance inst = new SparseInstance(d); //inst.setInstanceInformation(this.instanceInformation); return inst; }
protected Instance newSparseInstance(double d, double[] res) { Instance inst = new SparseInstance(d, res); //is it dense? //inst.setInstanceInformation(this.instanceInformation); return inst; }
@Override protected Instance newSparseInstance(double d, double[] res) { return new SparseInstance(d, res); // TODO }
private Instance readInstanceSparse() { Instance instance = new SparseInstance(1.0, null); //(this.instanceInformation.numAttributes() + 1);
Instance inst = new SparseInstance(1.0, attVals); inst.setDataset(getHeader()); inst.setClassValue((votes[1] > votes[2]) ? 0 : 1);
instance = new SparseInstance(inst.weight(), vals); } else { instance = new DenseInstance(inst.weight(), vals);
Instance x_ml = new SparseInstance(this.multilabelStreamTemplate.numAttributes()); x_ml.setDataset(this.multilabelStreamTemplate);
/** * Samoa instance from weka instance. * * @param inst the inst * @return the instance */ public Instance samoaInstance(weka.core.Instance inst) { Instance samoaInstance; if (inst instanceof weka.core.SparseInstance) { double[] attributeValues = new double[inst.numValues()]; int[] indexValues = new int[inst.numValues()]; for (int i = 0; i < inst.numValues(); i++) { if (inst.index(i) != inst.classIndex()) { attributeValues[i] = inst.valueSparse(i); indexValues[i] = inst.index(i); } } samoaInstance = new SparseInstance(inst.weight(), attributeValues, indexValues, inst.numAttributes()); } else { samoaInstance = new DenseInstance(inst.weight(), inst.toDoubleArray()); //samoaInstance.deleteAttributeAt(inst.classIndex()); } if (this.samoaInstanceInformation == null) { this.samoaInstanceInformation = this.samoaInstancesInformation(inst.dataset()); } samoaInstance.setDataset(samoaInstanceInformation); samoaInstance.setClassValue(inst.classValue()); return samoaInstance; }