@ Override public void compute2 ( ) { if ( Job . isRunning ( _jobKey ) ) { Timer timer = new Timer ( ) ; _stats [ 0 ] = new ThreadLocal < hex . singlenoderf . Statistic > ( ) ; _stats [ 1 ] = new ThreadLocal < hex . singlenoderf . Statistic > ( ) ; Data d = _sampler . sample ( _data , _seed , _modelKey , _local_mode ) ; hex . singlenoderf . Statistic left = getStatistic ( 0 , d , _seed , _exclusiveSplitLimit ) ; // calculate the split for ( Row r : d ) left . addQ ( r , _regression ) ; if ( ! _regression ) left . applyClassWeights ( ) ; // Weight the distributions hex . singlenoderf . Statistic . Split spl = left . split ( d , false ) ; if ( spl . isLeafNode ( ) ) { if ( _regression ) { float av = d . computeAverage ( ) ; _tree = new LeafNode ( - 1 , d . rows ( ) , av ) ; } else { _tree = new LeafNode ( _data . unmapClass ( spl . _split ) , d . rows ( ) , - 1 ) ; } } else { _tree = new FJBuild ( spl , d , 0 , _seed ) . compute ( ) ; } _stats = null ; // GC if ( _jobKey != null && ! Job . isRunning ( _jobKey ) ) throw new Job . JobCancelledException ( ) ; // Atomically improve the Model as well Key tkey = toKey ( ) ; Key dtreeKey = null ; if ( _score_pojo ) dtreeKey = toCompressedKey ( ) ; appendKey ( _modelKey , tkey , dtreeKey , _verbose > 10 ? _tree . toString ( new StringBuilder ( "" ) , Integer . MAX_VALUE ) . toString ( ) : "" , _data_id ) ; // appendKey(_modelKey, tkey, _verbose > 10 ? _tree.toString(new StringBuilder(""), Integer.MAX_VALUE).toString() : "", _data_id); StringBuilder sb = new StringBuilder ( "[RF] Tree : " ) . append ( _data_id + 1 ) ; sb . append ( " d=" ) . append ( _tree . depth ( ) ) . append ( " leaves=" ) . append ( _tree . leaves ( ) ) . append ( " done in " ) . append ( timer ) . append ( ' ' ) ; Log . info ( sb . toString ( ) ) ; if ( _verbose > 10 ) { // Log.info(Sys.RANDF, _tree.toString(sb, Integer.MAX_VALUE).toString()); // Log.info(Sys.RANDF, _tree.toJava(sb, Integer.MAX_VALUE).toString()); } } else throw new Job . JobCancelledException ( ) ; // Wait for completion tryComplete ( ) ; }
Actually build the tree