public void split ( final String inFile , final String outPath , boolean perUser , long seed , String delimiter , boolean isTemporalData ) { try { if ( delimiter == null ) delimiter = this . delimiter ; DataModelIF < Long , Long > [ ] splits = new CrossValidationSplitter < Long , Long > ( this . numFolds , perUser , seed ) . split ( new SimpleParser ( ) . parseData ( new File ( inFile ) , delimiter , isTemporalData ) ) ; File dir = new File ( outPath ) ; if ( ! dir . exists ( ) ) { if ( ! dir . mkdirs ( ) ) { log . error ( "Directory {} could not be created" , dir ) ; return ; } } for ( int i = 0 ; i < splits . length / 2 ; i ++ ) { DataModelIF < Long , Long > training = splits [ 2 * i ] ; DataModelIF < Long , Long > test = splits [ 2 * i + 1 ] ; String trainingFile = Paths . get ( outPath , "train_" + i + FILE_EXT ) . toString ( ) ; String testFile = Paths . get ( outPath , "test_" + i + FILE_EXT ) . toString ( ) ; log . info ( "train model fold {}: {}" , ( i + 1 ) , trainingFile ) ; log . info ( "test: model fold {}: {}" , ( i + 1 ) , testFile ) ; try { DataModelUtils . saveDataModel ( training , trainingFile , true , "\t" ) ; DataModelUtils . saveDataModel ( test , testFile , true , "\t" ) ; } catch ( FileNotFoundException | UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } } } catch ( IOException e ) { e . printStackTrace ( ) ; } }
Load a dataset and stores the splits generated from it .