Search in sources :

Example 1 with ClassLabel

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);
}
Also used : ClassLabel(edu.cmu.minorthird.classify.ClassLabel) Classifier(edu.cmu.minorthird.classify.Classifier)

Example 2 with ClassLabel

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);
    }
}
Also used : ClassifierLearner(edu.cmu.minorthird.classify.ClassifierLearner) ClassLabel(edu.cmu.minorthird.classify.ClassLabel) Example(edu.cmu.minorthird.classify.Example)

Example 3 with ClassLabel

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;
}
Also used : ClassLabel(edu.cmu.minorthird.classify.ClassLabel) Classifier(edu.cmu.minorthird.classify.Classifier)

Example 4 with ClassLabel

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;
}
Also used : ClassLabel(edu.cmu.minorthird.classify.ClassLabel) ArrayList(java.util.ArrayList) AnswerType(info.ephyra.questionanalysis.atype.AnswerType)

Example 5 with ClassLabel

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;
}
Also used : ClassLabel(edu.cmu.minorthird.classify.ClassLabel) MutableInstance(edu.cmu.minorthird.classify.MutableInstance) Instance(edu.cmu.minorthird.classify.Instance) Example(edu.cmu.minorthird.classify.Example)

Aggregations

ClassLabel (edu.cmu.minorthird.classify.ClassLabel)7 Example (edu.cmu.minorthird.classify.Example)3 Instance (edu.cmu.minorthird.classify.Instance)3 Classifier (edu.cmu.minorthird.classify.Classifier)2 MutableInstance (edu.cmu.minorthird.classify.MutableInstance)2 ClassifierLearner (edu.cmu.minorthird.classify.ClassifierLearner)1 AnswerType (info.ephyra.questionanalysis.atype.AnswerType)1 Result (info.ephyra.search.Result)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1