Beispiel #1
0
double ConfusionMatrix::averageClassAccuracy(bool includeVoid) const {

    if (!normalized) {
        ConfusionMatrix normalizedConfusionMatrix(*this);
        normalizedConfusionMatrix.normalize();
        assert(normalizedConfusionMatrix.isNormalized());
        return normalizedConfusionMatrix.averageClassAccuracy(includeVoid);
    }

    utils::Average averageClassAccuracy;

    for (unsigned int label = 0; label < getNumClasses(); label++) {
        double classAccuracy = data(label, label);
        assertProbability(classAccuracy);
 
        bool ignore = false;
        if (!includeVoid && !ignoredLabels.empty())
        	for (LabelType ID: ignoredLabels)
        		if (ID == label)
       			{
       				ignore = true;
       				break;
       			}
        if (ignore)
        	continue;
        else
        	averageClassAccuracy.addValue(classAccuracy);
    }

    return averageClassAccuracy.getAverage();
}
Beispiel #2
0
double ConfusionMatrix::averageClassAccuracy(bool includeVoid) const {

    if (!normalized) {
        ConfusionMatrix normalizedConfusionMatrix(*this);
        normalizedConfusionMatrix.normalize();
        assert(normalizedConfusionMatrix.isNormalized());
        return normalizedConfusionMatrix.averageClassAccuracy(includeVoid);
    }

    utils::Average averageClassAccuracy;

    for (unsigned int label = 0; label < getNumClasses(); label++) {
        double classAccuracy = data(label, label);
        assertProbability(classAccuracy);
        if (includeVoid || label > 0) {
            averageClassAccuracy.addValue(classAccuracy);
        }
    }

    return averageClassAccuracy.getAverage();
}