Commits

Aaron Wong  committed 4367400

Apply laplace smoothing consistently (whether regularization is used). This fixes a bug where datasets with alphas equal to zero (no regularizing) where not laplace smoothed.

  • Participants
  • Parent commits 96bfe4f
  • Branches counter_missing_zeros

Comments (0)

Files changed (2)

 *.o
 *~
 tools/*/*.am
+tools/PCLDistancer
+tools/FAer
 config.status
 Makefile
 aclocal.m4
 syntax: regexp
 # ignore the binaries
 ^tools/(?P<tool>[^/]*)/(?P=tool)$
-hgignore
+hgignore

File src/bayesnetfn.cpp

 		  // skip zero                                                                                                                                                                                                       
                   if(dTotal == 0 && dAlpha == 0)
                     vecdProbs[ i ] = 1.0 / vecdProbs.size( );
-                  else
-                    vecdProbs[ i ] = ( ( dScale * veciCounts[ i ] ) + dAlpha ) /
+                  else // laplace smooth and regularize 
+                    vecdProbs[ i ] = ( ( dScale * (veciCounts[ i ] + 1) ) + dAlpha ) /
                       ( dTotal + ( dAlpha * vecdProbs.size( ) ) );
 		}
 	}
 				break;
 
 			case c_iStateCPT:
-				if( !Counts2Probs( vecstrLine, vecdProbs, vecdAlphas.empty( ) ? 1 : vecdAlphas[ iNode ],
+				if( !Counts2Probs( vecstrLine, vecdProbs, vecdAlphas.empty( ) ? 0 : vecdAlphas[ iNode ],
 					dPseudocounts, pBNDefault, iNode, iClass ) )
 					return false;
 				{