question: protected Instances generateSubset ( Instances data , Range range ) throws Exception { Remove filter ; StringBuilder atts ; Instances result ; int [ ] indices ; int i ; indices = range . getSelection ( ) ; atts = new StringBuilder ( ) ; for ( i = 0 ; i < indices . length ; i ++ ) { if ( i > 0 ) { atts . append ( "," ) ; } atts . append ( "" + ( indices [ i ] + 1 ) ) ; } if ( ( data . classIndex ( ) > - 1 ) && ( ! range . isInRange ( data . classIndex ( ) ) ) ) { atts . append ( "," + ( data . classIndex ( ) + 1 ) ) ; } filter = new Remove ( ) ; filter . setAttributeIndices ( atts . toString ( ) ) ; filter . setInvertSelection ( true ) ; filter . setInputFormat ( data ) ; result = Filter . useFilter ( data , filter ) ; return result ; }
target:  generates a subset of the dataset with only the attributes from the range (class is always added if present).