public Table [ ] sampleSplit ( double table1Proportion ) { Table [ ] tables = new Table [ 2 ] ; int table1Count = ( int ) Math . round ( rowCount ( ) * table1Proportion ) ; Selection table2Selection = new BitmapBackedSelection ( ) ; for ( int i = 0 ; i < rowCount ( ) ; i ++ ) { table2Selection . add ( i ) ; } Selection table1Selection = new BitmapBackedSelection ( ) ; Selection table1Records = selectNRowsAtRandom ( table1Count , rowCount ( ) ) ; for ( int table1Record : table1Records ) { table1Selection . add ( table1Record ) ; } table2Selection . andNot ( table1Selection ) ; tables [ 0 ] = where ( table1Selection ) ; tables [ 1 ] = where ( table2Selection ) ; return tables ; }
Splits the table into two randomly assigning records to each according to the proportion given in trainingProportion