private ClassifierKS getPreviousClassifier ( Classifier classifier , List < Instance > instances ) { ExecutorService threadPool = Executors . newFixedThreadPool ( this . threadSizeOption . getValue ( ) ) ; int SIZE = this . classifiers . size ( ) ; Map < Integer , Future < Double > > futures = new HashMap <> ( ) ; for ( int i = 0 ; i < SIZE ; i ++ ) { ClassifierKS cs = this . classifiers . get ( i ) ; if ( cs != null ) { if ( cs . getClassifier ( ) != classifier ) { StatisticalTest st = ( StatisticalTest ) getPreparedClassOption ( this . statisticalTestOption ) ; StatisticalTest temp = ( StatisticalTest ) st . copy ( ) ; temp . set ( instances , cs . getInstances ( ) ) ; futures . put ( i , threadPool . submit ( temp ) ) ; } } else { break ; } } ClassifierKS cks = null ; int qtd = this . quantityClassifiersTestOption . getValue ( ) ; double maxPValue = this . similarityBetweenDistributionsOption . getValue ( ) ; try { for ( int i = 0 ; i < SIZE && qtd > 0 ; i ++ ) { Future < Double > f = futures . get ( i ) ; if ( f != null ) { double p = f . get ( ) ; if ( p < maxPValue ) { maxPValue = p ; cks = this . classifiers . get ( i ) ; qtd -- ; } } } } catch ( InterruptedException e ) { System . out . println ( "Processing interrupted." ) ; } catch ( ExecutionException e ) { throw new RuntimeException ( "Error computing statistical test." , e ) ; } threadPool . shutdownNow ( ) ; return cks ; }
Searches for the classifier best suited for actual data . All statistical tests are performed in parallel .