private void calculateEntropy(double stop,KStarWrapper params){
  int i, j, k;
  Instance train;
  double actent=0.0, randent=0.0;
  double pstar, tprob, psum=0.0, minprob=1.0;
  double actClassProb, randClassProb;
  double[][] pseudoClassProb=new double[NUM_RAND_COLS + 1][m_NumClasses];
  for (j=0; j <= NUM_RAND_COLS; j++) {
    for (i=0; i < m_NumClasses; i++) {
      pseudoClassProb[j][i]=0.0;
    }
  }
  for (i=0; i < m_NumInstances; i++) {
    train=m_TrainSet.instance(i);
    if (!train.isMissing(m_AttrIndex)) {
      pstar=PStar(m_Test,train,m_AttrIndex,stop);
      tprob=pstar / m_TotalCount;
      if (pstar < minprob) {
        minprob=pstar;
      }
      psum+=tprob;
      for (k=0; k <= NUM_RAND_COLS; k++) {
        pseudoClassProb[k][m_RandClassCols[k][i]]+=tprob;
      }
    }
  }
  for (j=m_NumClasses - 1; j >= 0; j--) {
    actClassProb=pseudoClassProb[NUM_RAND_COLS][j] / psum;
    if (actClassProb > 0) {
      actent-=actClassProb * Math.log(actClassProb) / LOG2;
    }
  }
  for (k=0; k < NUM_RAND_COLS; k++) {
    for (i=m_NumClasses - 1; i >= 0; i--) {
      randClassProb=pseudoClassProb[k][i] / psum;
      if (randClassProb > 0) {
        randent-=randClassProb * Math.log(randClassProb) / LOG2;
      }
    }
  }
  randent/=NUM_RAND_COLS;
  params.actEntropy=actent;
  params.randEntropy=randent;
  params.avgProb=psum;
  params.minProb=minprob;
}

private void calculateEntropy ( double stop , KStarWrapper params ) { int i , j , k ; Instance train ; double actent = 0.0 , randent = 0.0 ; double pstar , tprob , psum = 0.0 , minprob = 1.0 ; double actClassProb , randClassProb ; double [ ] [ ] pseudoClassProb = new double [ NUM_RAND_COLS + 1 ] [ m_NumClasses ] ; for ( j = 0 ; j <= NUM_RAND_COLS ; j ++ ) { for ( i = 0 ; i < m_NumClasses ; i ++ ) { pseudoClassProb [ j ] [ i ] = 0.0 ; } } for ( i = 0 ; i < m_NumInstances ; i ++ ) { train = m_TrainSet . instance ( i ) ; if ( ! train . isMissing ( m_AttrIndex ) ) { pstar = PStar ( m_Test , train , m_AttrIndex , stop ) ; tprob = pstar / m_TotalCount ; if ( pstar < minprob ) { minprob = pstar ; } psum += tprob ; for ( k = 0 ; k <= NUM_RAND_COLS ; k ++ ) { pseudoClassProb [ k ] [ m_RandClassCols [ k ] [ i ] ] += tprob ; } } } for ( j = m_NumClasses - 1 ; j >= 0 ; j -- ) { actClassProb = pseudoClassProb [ NUM_RAND_COLS ] [ j ] / psum ; if ( actClassProb > 0 ) { actent -= actClassProb * Math . log ( actClassProb ) / LOG2 ; } } for ( k = 0 ; k < NUM_RAND_COLS ; k ++ ) { for ( i = m_NumClasses - 1 ; i >= 0 ; i -- ) { randClassProb = pseudoClassProb [ k ] [ i ] / psum ; if ( randClassProb > 0 ) { randent -= randClassProb * Math . log ( randClassProb ) / LOG2 ; } } } randent /= NUM_RAND_COLS ; params . actEntropy = actent ; params . randEntropy = randent ; params . avgProb = psum ; params . minProb = minprob ; }
calculates the entropy of the actual class prediction and the entropy for random class prediction . it also calculates the smallest and average transformation probabilities .
