Search in sources :

Example 1 with Accuracy

use of de.unidue.ltl.evaluation.measures.Accuracy in project dkpro-tc by dkpro.

the class MultiSvmDocumentClassificationUsingWekaLibsvmLiblinearTest method getAccuracy.

private double getAccuracy(List<File> id2outcomeFiles, String simpleName) throws Exception {
    for (File f : id2outcomeFiles) {
        if (f.getAbsolutePath().toLowerCase().contains(simpleName.toLowerCase())) {
            EvaluationData<String> data = Tc2LtlabEvalConverter.convertSingleLabelModeId2Outcome(f);
            Accuracy<String> acc = new Accuracy<>(data);
            return acc.getResult();
        }
    }
    return -1;
}
Also used : Accuracy(de.unidue.ltl.evaluation.measures.Accuracy) File(java.io.File)

Example 2 with Accuracy

use of de.unidue.ltl.evaluation.measures.Accuracy in project dkpro-tc by dkpro.

the class LiblinearDocumentPlainTest method getAccuracy.

private double getAccuracy(List<File> id2outcomeFiles, String simpleName) throws Exception {
    for (File f : id2outcomeFiles) {
        if (f.getAbsolutePath().toLowerCase().contains(simpleName.toLowerCase())) {
            EvaluationData<String> data = Tc2LtlabEvalConverter.convertSingleLabelModeId2Outcome(f);
            Accuracy<String> acc = new Accuracy<>(data);
            return acc.getResult();
        }
    }
    return -1;
}
Also used : Accuracy(de.unidue.ltl.evaluation.measures.Accuracy) File(java.io.File)

Example 3 with Accuracy

use of de.unidue.ltl.evaluation.measures.Accuracy in project dkpro-tc by dkpro.

the class MultiSvmDocumentClassificationUsingWekaLibsvmLiblinearTest method getAccuracyCrossValidation.

private double getAccuracyCrossValidation(List<File> id2outcomeFiles, String simpleName) throws Exception {
    for (File f : id2outcomeFiles) {
        File file = new File(f.getParentFile(), "ATTRIBUTES.txt");
        Set<String> readSubTasks = readSubTasks(file);
        for (String k : readSubTasks) {
            File file2 = new File(f.getParentFile().getParentFile() + "/" + k, "ATTRIBUTES.txt");
            if (!file2.exists()) {
                continue;
            }
            Set<String> readSubTasks2 = readSubTasks(file2);
            for (String j : readSubTasks2) {
                if (j.toLowerCase().contains(simpleName.toLowerCase())) {
                    EvaluationData<String> data = Tc2LtlabEvalConverter.convertSingleLabelModeId2Outcome(f);
                    Accuracy<String> acc = new Accuracy<>(data);
                    return acc.getResult();
                }
            }
        }
    }
    return -1;
}
Also used : Accuracy(de.unidue.ltl.evaluation.measures.Accuracy) File(java.io.File)

Example 4 with Accuracy

use of de.unidue.ltl.evaluation.measures.Accuracy in project dkpro-tc by dkpro.

the class LibsvmDocumentPlainTest method getAccuracy.

private double getAccuracy(List<File> id2outcomeFiles, String simpleName) throws Exception {
    for (File f : id2outcomeFiles) {
        if (f.getAbsolutePath().toLowerCase().contains(simpleName.toLowerCase())) {
            EvaluationData<String> data = Tc2LtlabEvalConverter.convertSingleLabelModeId2Outcome(f);
            Accuracy<String> acc = new Accuracy<>(data);
            return acc.getResult();
        }
    }
    return -1;
}
Also used : Accuracy(de.unidue.ltl.evaluation.measures.Accuracy) File(java.io.File)

Example 5 with Accuracy

use of de.unidue.ltl.evaluation.measures.Accuracy in project dkpro-tc by dkpro.

the class SVMHMMBrownPosDemoTest method testSvmHmm.

@Test
public void testSvmHmm() throws Exception {
    pSpace = SvmHmmBrownPosDemo.getParameterSpace();
    javaExperiment.runTrainTest(pSpace);
    File inputFile = ContextMemoryReport.id2outcomeFiles.get(0);
    EvaluationData<String> data = Tc2LtlabEvalConverter.convertSingleLabelModeId2Outcome(pathVerification(inputFile));
    Accuracy<String> acc = new Accuracy<String>(data);
    assertEquals(0.3, acc.getResult(), 0.2);
    assertEquals(1, ContextMemoryReport.id2outcomeFiles.size());
    List<String> lines = FileUtils.readLines(ContextMemoryReport.id2outcomeFiles.get(0), "utf-8");
    assertEquals(34, lines.size());
    // line-wise compare
    assertEquals("#ID=PREDICTION;GOLDSTANDARD;THRESHOLD", lines.get(0));
    assertEquals("#labels 1=ABX 2=AP 3=AT 4=BEDZ 5=BEN 6=BER 7=CC 8=CS 9=DOD 10=DT 11=DTS 12=HV 13=HVD 14=IN 15=JJ 16=JJT 17=MD 18=NN 19=NNS 20=NP 21=NPg 22=PPO 23=PPS 24=QL 25=RB 26=TO 27=VB 28=VBD 29=VBG 30=VBN 31=WDT 32=pct", lines.get(1));
    assertTrue(lines.get(3).matches("0=[0-9]+;7;-1"));
    assertTrue(lines.get(4).matches("1=[0-9]+;2;-1"));
    assertTrue(lines.get(5).matches("10=[0-9]+;32;-1"));
    assertTrue(lines.get(6).matches("11=[0-9]+;17;-1"));
    assertTrue(lines.get(7).matches("12=[0-9]+;27;-1"));
    assertTrue(lines.get(8).matches("13=[0-9]+;19;-1"));
    assertTrue(lines.get(9).matches("14=[0-9]+;32;-1"));
    assertTrue(lines.get(10).matches("15=[0-9]+;18;-1"));
    assertTrue(lines.get(11).matches("16=[0-9]+;19;-1"));
    assertTrue(lines.get(12).matches("17=[0-9]+;32;-1"));
    assertTrue(lines.get(13).matches("18=[0-9]+;18;-1"));
    assertTrue(lines.get(14).matches("19=[0-9]+;19;-1"));
    assertTrue(lines.get(15).matches("2=[0-9]+;19;-1"));
    assertTrue(lines.get(16).matches("20=[0-9]+;18;-1"));
    assertTrue(lines.get(17).matches("21=[0-9]+;32;-1"));
    assertTrue(lines.get(18).matches("22=[0-9]+;3;-1"));
}
Also used : Accuracy(de.unidue.ltl.evaluation.measures.Accuracy) File(java.io.File) Test(org.junit.Test)

Aggregations

Accuracy (de.unidue.ltl.evaluation.measures.Accuracy)6 File (java.io.File)5 EvaluationData (de.unidue.ltl.evaluation.core.EvaluationData)1 EvaluationMeasure (de.unidue.ltl.evaluation.measures.EvaluationMeasure)1 PearsonCorrelation (de.unidue.ltl.evaluation.measures.correlation.PearsonCorrelation)1 SpearmanCorrelation (de.unidue.ltl.evaluation.measures.correlation.SpearmanCorrelation)1 ExactMatchRatio (de.unidue.ltl.evaluation.measures.multilabel.ExactMatchRatio)1 HammingLoss (de.unidue.ltl.evaluation.measures.multilabel.HammingLoss)1 MultilabelAccuracy (de.unidue.ltl.evaluation.measures.multilabel.MultilabelAccuracy)1 MeanAbsoluteError (de.unidue.ltl.evaluation.measures.regression.MeanAbsoluteError)1 MeanSquaredError (de.unidue.ltl.evaluation.measures.regression.MeanSquaredError)1 RSquared (de.unidue.ltl.evaluation.measures.regression.RSquared)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1