use of edu.cmu.minorthird.classify.ClassLabel in project lucida by claritylab.
the class HierarchicalClassifier method classification.
public ClassLabel classification(Instance instance) {
String labelName = "";
double weight = 1;
for (int i = 0; i < classLevels; i++) {
Classifier currentClassifier = (Classifier) classifiers.get(labelName);
ClassLabel currentLabel = currentClassifier.classification(instance);
labelName = getNewLabelName(labelName, currentLabel.bestClassName(), i);
weight *= currentLabel.bestWeight();
}
return new ClassLabel(labelName, weight);
}
use of edu.cmu.minorthird.classify.ClassLabel in project lucida by claritylab.
the class HierarchicalClassifierLearner method addExample.
public void addExample(Example example) {
for (int i = 0; i < prototypes.length; i++) {
String labelName = example.getLabel().bestClassName();
String prefix = getLabelPrefix(labelName, i);
String sublabel = getSublabel(labelName, i);
Example subExample = new Example(example.asInstance(), new ClassLabel(sublabel));
ClassifierLearner subLearner = classifierLearners.get(prefix);
subLearner.addExample(subExample);
}
}
use of edu.cmu.minorthird.classify.ClassLabel in project lucida by claritylab.
the class HierarchicalClassifier method explain.
public String explain(Instance instance) {
String labelName = "";
String explanation = "";
for (int i = 0; i < classLevels; i++) {
Classifier currentClassifier = (Classifier) classifiers.get(labelName);
ClassLabel currentLabel = currentClassifier.classification(instance);
labelName = getNewLabelName(labelName, currentLabel.bestClassName(), i);
explanation += currentClassifier.explain(instance);
}
return explanation;
}
use of edu.cmu.minorthird.classify.ClassLabel in project lucida by claritylab.
the class TrainedQuestionClassifier method classify.
public List<AnswerType> classify(Instance instance) {
List<AnswerType> res = new ArrayList<AnswerType>();
ClassLabel label = null;
synchronized (classifier) {
label = classifier.classification(instance);
}
String labelStr = label.bestClassName().replaceAll("-", ".");
AnswerType atype = AnswerType.constructFromString(labelStr);
double weight = label.bestWeight();
if (weight > 1.0)
weight = (1 - (1 / weight));
atype.setConfidence(weight);
res.add(atype);
return res;
}
use of edu.cmu.minorthird.classify.ClassLabel in project lucida by claritylab.
the class ScoreNormalizationFilter method createExample.
/**
* Creates a training/evaluation example from a judged answer candidate.
*
* @param features selected features
* @param result judged answer candidate
* @param results all answers to the question
* @param qid question ID
* @return training/evaluation example
*/
private static Example createExample(String[] features, Result result, Result[] results, String qid) {
// create instance with selected features
Instance instance = createInstance(features, result, results, qid);
// create example from the instance and its class label
String label = result.isCorrect() ? ExampleSchema.POS_CLASS_NAME : ExampleSchema.NEG_CLASS_NAME;
Example example = new Example(instance, new ClassLabel(label));
return example;
}
Aggregations