private HashMap<String, Double> getObjectClassProbabilities(
String objectName, String workerToIgnore) {
HashMap<String, Double> result = new HashMap<String, Double>();
Datum d = this.objects.get(objectName);
// If this is a gold example, just put the probability estimate to be
// 1.0
// for the correct class
if (d.isGold()) {
for (String category : this.categories.keySet()) {
String correctCategory = d.getGoldCategory();
if (category.equals(correctCategory)) {
result.put(category, 1.0);
} else {
result.put(category, 0.0);
}
}
return result;
}
// Let's check first if we have any workers who have labeled this item,
// except for the worker that we ignore
Set<AssignedLabel> labels = d.getAssignedLabels();
if (labels.isEmpty())
return null;
if (workerToIgnore != null && labels.size() == 1) {
for (AssignedLabel al : labels) {
if (al.getWorkerName().equals(workerToIgnore))
return null;
}
}
// If it is not gold, then we proceed to estimate the class
// probabilities using the method of Dawid and Skene and we proceed as
// usual with the M-phase of the EM-algorithm of Dawid&Skene
// Estimate denominator for Eq 2.5 of Dawid&Skene, which is the same
// across all categories
Double denominator = 0.0;
// To compute the denominator, we also compute the nominators across
// all categories, so it saves us time to save the nominators as we
// compute them
HashMap<String, Double> categoryNominators = new HashMap<String, Double>();
for (Category category : categories.values()) {
// We estimate now Equation 2.5 of Dawid & Skene
Double categoryNominator = category.getPrior();
// We go through all the labels assigned to the d object
for (AssignedLabel al : d.getAssignedLabels()) {
Worker w = workers.get(al.getWorkerName());
// If we are trying to estimate the category probability
// distribution
// to estimate the quality of a given worker, then we need to