public weka . core . Instance wekaInstance ( Instance inst ) { weka . core . Instance wekaInstance ; if ( ( ( InstanceImpl ) inst ) . instanceData instanceof SparseInstanceData ) { InstanceImpl instance = ( InstanceImpl ) inst ; SparseInstanceData sparseInstanceData = ( SparseInstanceData ) instance . instanceData ; wekaInstance = new weka . core . SparseInstance ( instance . weight ( ) , sparseInstanceData . getAttributeValues ( ) , sparseInstanceData . getIndexValues ( ) , sparseInstanceData . getNumberAttributes ( ) ) ; /*if (this.wekaInstanceInformation == null) { this.wekaInstanceInformation = this.wekaInstancesInformation(inst.dataset()); } wekaInstance.insertAttributeAt(inst.classIndex()); wekaInstance.setDataset(wekaInstanceInformation); wekaInstance.setClassValue(inst.classValue()); //wekaInstance.setValueSparse(wekaInstance.numAttributes(), inst.classValue());*/ } else { Instance instance = inst ; wekaInstance = new weka . core . DenseInstance ( instance . weight ( ) , instance . toDoubleArray ( ) ) ; /* if (this.wekaInstanceInformation == null) { this.wekaInstanceInformation = this.wekaInstancesInformation(inst.dataset()); } //We suppose that the class is the last attibute. We should deal when this is not the case wekaInstance.insertAttributeAt(inst.classIndex()); wekaInstance.setDataset(wekaInstanceInformation); wekaInstance.setClassValue(inst.classValue());*/ } if ( this . wekaInstanceInformation == null ) { this . wekaInstanceInformation = this . wekaInstancesInformation ( inst . dataset ( ) ) ; } //wekaInstance.insertAttributeAt(inst.classIndex()); wekaInstance . setDataset ( wekaInstanceInformation ) ; if ( inst . numOutputAttributes ( ) == 1 ) { wekaInstance . setClassValue ( inst . classValue ( ) ) ; } return wekaInstance ; }
Weka instance .