首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >什么是平均概率?在“vote”部分中

什么是平均概率?在“vote”部分中
EN

Stack Overflow用户
提问于 2012-12-16 19:48:03
回答 1查看 615关注 0票数 1

Weka中使用的概率的平均值是多少?distributionForInstanceAverage中的代码在做什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-12-30 23:05:27

它只是返回每个基本分类器的概率分布的平均值(在投票中学习或在外部构建并通过投票加载)。

它首先对在投票中学习的任何模型进行求和,然后加载任何模型,然后按元素将数组除以模型总数。

代码语言:javascript
复制
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;
  }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13900997

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档