question: @ Override public void endOfStream ( ) throws AdeException { double minProb = 1 ; if ( m_totalIntervalCount == 0 ) { m_totalIntervalCount = 1 ; } for ( Entry < String , BernoulliScore . MsgData > entry : m_msgData . entrySet ( ) ) { final FullBernoulliMsgData data = ( FullBernoulliMsgData ) entry . getValue ( ) ; data . m_prob = ( ( double ) data . m_count + 0.5 ) / ( m_totalIntervalCount + 1.0 ) ; if ( data . m_prob < 0 || data . m_prob >= 1.0 ) { logger . info ( entry . getKey ( ) + ":  bad m_prob: " + data . m_prob + "=" + data . m_count + "+0.5 / " + m_totalIntervalCount + "+1" ) ; } if ( data . m_prob < minProb ) { minProb = data . m_prob ; } data . m_outOfClusterProb = ( ( double ) data . m_outOfClusterCount + 0.5 ) / ( m_totalIntervalCount + 1.0 ) ; if ( data . m_outOfClusterCount < minProb && data . m_outOfClusterCount > 0.0 ) { minProb = data . m_outOfClusterCount ; } } for ( BernoulliScore . MsgData dataSuper : m_msgData . values ( ) ) { final FullBernoulliMsgData data = ( FullBernoulliMsgData ) dataSuper ; final double probability = data . m_prob ; data . m_score = - Math . log ( probability ) ; if ( data . m_score > 1 ) { data . m_score = 1 ; } final double outOfContextProbability = data . m_outOfClusterProb ; data . m_outOfContextScore = - Math . log ( outOfContextProbability ) ; if ( data . m_outOfContextScore > 1 ) { data . m_outOfContextScore = 1 ; } } m_trained = true ; }
target:  Calculate the probabilities and scores for each message's data after going through all the analyzed intervals. Message probability is calculated by dividing the total number of times the message appeared by the total number of analyzed intervals gone through. The message score is calculated by taking the negative log of the message probability. Out of cluster  probability and out of context score are also calculated.