2012-12-16 90 views

回答

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; 
    } 
+0

非常感謝你 –