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 ) ; if ( inst . classIndex ( ) >= 0 ) { // class attribute is present samoaInstance . setClassValue ( inst . classValue ( ) ) ; } return samoaInstance ; }
Samoa instance from weka instance .