Weka使用的概率平均值是多少? distributionForInstanceAverage
里面的代码是什么?
答案 0 :(得分:0)
它只返回每个基本分类器的概率分布的均值(在投票中学习或在外部构建并由投票加载)。
首先对在Vote中学习的任何模型进行总结,然后加载任何模型,然后按元素方式将数组除以模型总数。
protected double[] distributionForInstanceAverage(Instance instance) throws Exception {
//Init probs array with first classifier used within model (learnt or loaded)
double[] probs = (m_Classifiers.length > 0)
? getClassifier(0).distributionForInstance(instance)
: m_preBuiltClassifiers.get(0).distributionForInstance(instance);
//Add the distributions of any classifiers built within the Vote classifier to probs array
for (int i = 1; i < m_Classifiers.length; i++) {
double[] dist = getClassifier(i).distributionForInstance(instance);
for (int j = 0; j < dist.length; j++) {
probs[j] += dist[j];
}
}
//Add the distributions of any classifiers built outside of the Vote classifier (loaded in) to the probs array
int index = (m_Classifiers.length > 0) ? 0 : 1;
for (int i = index; i < m_preBuiltClassifiers.size(); i++) {
double[] dist = m_preBuiltClassifiers.get(i).distributionForInstance(instance);
for (int j = 0; j < dist.length; j++) {
probs[j] += dist[j];
}
}
//Divide each probability by the total number of classifiers used in Vote (to get the mean)
for (int j = 0; j < probs.length; j++) {
probs[j] /= (double)(m_Classifiers.length + m_preBuiltClassifiers.size());
}
return probs;
}