package NaviveBayesClassify;.net
/**get
* 先驗機率計算it
* <h3>先驗機率計算</h3>io
* P(c<sub>j</sub>)=N(C=c<sub>j</sub>)<b>/</b>N <br>class
* 其中,N(C=c<sub>j</sub>)表示類別c<sub>j</sub>中的訓練文本數量;float
* N表示訓練文本集總數量。static
*/vi
public class PriorProbability new
{return
private static TrainingDataManager tdm =new TrainingDataManager();
/**
* 先驗機率
* @param c 給定的分類
* @return 給定條件下的先驗機率
*/
public static float calculatePc(String c)
{
float ret = 0F;
float Nc = tdm.getTrainingFileCountOfClassification(c);
float N = tdm.getTrainingFileCount();
ret = Nc / N;
return ret;
}
}