question: private int [ ] createEqualPartition ( double [ ] ratio , int size , Attribute label ) { List < ExampleIndex > examples = new ArrayList < ExampleIndex > ( size ) ; Iterator < Example > reader = exampleSet . iterator ( ) ; int index = 0 ; while ( reader . hasNext ( ) ) { Example example = reader . next ( ) ; examples . add ( new ExampleIndex ( index ++ , example . getNominalValue ( label ) ) ) ; } Collections . shuffle ( examples , random ) ; Collections . sort ( examples ) ; List < ExampleIndex > newExamples = new ArrayList < ExampleIndex > ( size ) ; int start = 0 ; int numberOfPartitions = ratio . length ; while ( newExamples . size ( ) < size ) { for ( int i = start ; i < examples . size ( ) ; i += numberOfPartitions ) { newExamples . add ( examples . get ( i ) ) ; } start ++ ; } int [ ] startNewP = new int [ ratio . length + 1 ] ; startNewP [ 0 ] = 0 ; double ratioSum = 0 ; for ( int i = 1 ; i < startNewP . length ; i ++ ) { ratioSum += ratio [ i - 1 ] ; startNewP [ i ] = ( int ) Math . round ( newExamples . size ( ) * ratioSum ) ; } int [ ] part = new int [ newExamples . size ( ) ] ; int p = 0 ; int counter = 0 ; Iterator < ExampleIndex > n = newExamples . iterator ( ) ; while ( n . hasNext ( ) ) { if ( counter >= startNewP [ p + 1 ] ) { p ++ ; } ExampleIndex exampleIndex = n . next ( ) ; part [ exampleIndex . exampleIndex ] = p ; counter ++ ; } return part ; }
target:  Returns a stratified partition for the given example set. The examples must have a nominal label.