Exemplo n.º 1
0
 /**
  * 计算P(feature|cateogry),返回的是取对数后的数值
  *
  * @param feature
  * @param category
  * @return
  */
 public double getFeatureProbability(String feature, String category) {
   int m = VARIABLE.getFeatureCount();
   return Math.log(
       (VARIABLE.getDocCount(feature, category) + 1.0) / (VARIABLE.getDocCount(category) + m));
 }
Exemplo n.º 2
0
 /**
  * 计算P(C)=该类型文档总数/文档总数,返回的数对数值
  *
  * @param category
  * @return
  */
 public double getCategoryProbability(String category) {
   return Math.log(VARIABLE.getDocCount(category) * 1.0f / VARIABLE.getDocCount());
 }