Search in sources :

Example 1 with MeanSquaredError

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

the class MultiRegressionUsingWekaLibsvmLiblinearTest method getMeanSquaredErrorCrossValidation.

private double getMeanSquaredErrorCrossValidation(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 s : readSubTasks) {
            File file2 = new File(f.getParentFile().getParentFile() + "/" + s, "ATTRIBUTES.txt");
            if (!file2.exists()) {
                continue;
            }
            Set<String> readSubTasks2 = readSubTasks(file2);
            for (String k : readSubTasks2) {
                if (k.toLowerCase().contains(simpleName.toLowerCase())) {
                    EvaluationData<Double> data = Tc2LtlabEvalConverter.convertRegressionModeId2Outcome(f);
                    MeanSquaredError mse = new MeanSquaredError(data);
                    return mse.getResult();
                }
            }
        }
    }
    return -1;
}
Also used : MeanSquaredError(de.unidue.ltl.evaluation.measures.regression.MeanSquaredError) File(java.io.File)

Example 2 with MeanSquaredError

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

the class MultiRegressionUsingWekaLibsvmLiblinearTest method getMeanSquaredError.

private double getMeanSquaredError(List<File> id2outcomeFiles, String simpleName) throws Exception {
    for (File f : id2outcomeFiles) {
        if (f.getAbsolutePath().contains(simpleName + "TestTask-")) {
            EvaluationData<Double> data = Tc2LtlabEvalConverter.convertRegressionModeId2Outcome(f);
            MeanSquaredError mse = new MeanSquaredError(data);
            return mse.getResult();
        }
    }
    return -1;
}
Also used : MeanSquaredError(de.unidue.ltl.evaluation.measures.regression.MeanSquaredError) File(java.io.File)

Example 3 with MeanSquaredError

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

the class MetricComputationUtil method getResults.

public static Map<String, String> getResults(File id2o, String mode) throws Exception {
    if (mode == null) {
        throw new IllegalArgumentException("The learning mode is null");
    }
    Map<String, String> map = new HashMap<>();
    if (mode.equals(Constants.LM_SINGLE_LABEL)) {
        EvaluationData<String> data = Tc2LtlabEvalConverter.convertSingleLabelModeId2Outcome(id2o);
        Accuracy<String> acc = new Accuracy<>(data);
        map.put(acc.getClass().getSimpleName(), "" + acc.getResult());
    } else if (mode.equals(Constants.LM_REGRESSION)) {
        EvaluationData<Double> data = Tc2LtlabEvalConverter.convertRegressionModeId2Outcome(id2o);
        EvaluationMeasure<?> m = new RSquared(data);
        map.put(m.getClass().getSimpleName(), getExceptionFreeResult(m));
        m = new PearsonCorrelation(data);
        map.put(m.getClass().getSimpleName(), getExceptionFreeResult(m));
        m = new SpearmanCorrelation(data);
        map.put(m.getClass().getSimpleName(), getExceptionFreeResult(m));
        m = new MeanSquaredError(data);
        map.put(m.getClass().getSimpleName(), getExceptionFreeResult(m));
        m = new MeanAbsoluteError(data);
        map.put(m.getClass().getSimpleName(), getExceptionFreeResult(m));
    } else if (mode.equals(Constants.LM_MULTI_LABEL)) {
        EvaluationData<String> data = Tc2LtlabEvalConverter.convertMultiLabelModeId2Outcome(id2o);
        EvaluationMeasure<?> m = new ExactMatchRatio<>(data);
        map.put(m.getClass().getSimpleName(), getExceptionFreeResult(m));
        EvaluationData<Integer> dataInt = Tc2LtlabEvalConverter.convertMultiLabelModeId2OutcomeUseInteger(id2o);
        m = new HammingLoss(dataInt);
        map.put(m.getClass().getSimpleName(), getExceptionFreeResult(m));
        m = new MultilabelAccuracy(dataInt);
        map.put(m.getClass().getSimpleName(), getExceptionFreeResult(m));
    }
    return map;
}
Also used : RSquared(de.unidue.ltl.evaluation.measures.regression.RSquared) EvaluationData(de.unidue.ltl.evaluation.core.EvaluationData) MultilabelAccuracy(de.unidue.ltl.evaluation.measures.multilabel.MultilabelAccuracy) HashMap(java.util.HashMap) MeanAbsoluteError(de.unidue.ltl.evaluation.measures.regression.MeanAbsoluteError) PearsonCorrelation(de.unidue.ltl.evaluation.measures.correlation.PearsonCorrelation) HammingLoss(de.unidue.ltl.evaluation.measures.multilabel.HammingLoss) Accuracy(de.unidue.ltl.evaluation.measures.Accuracy) MultilabelAccuracy(de.unidue.ltl.evaluation.measures.multilabel.MultilabelAccuracy) MeanSquaredError(de.unidue.ltl.evaluation.measures.regression.MeanSquaredError) ExactMatchRatio(de.unidue.ltl.evaluation.measures.multilabel.ExactMatchRatio) SpearmanCorrelation(de.unidue.ltl.evaluation.measures.correlation.SpearmanCorrelation) EvaluationMeasure(de.unidue.ltl.evaluation.measures.EvaluationMeasure)

Aggregations

MeanSquaredError (de.unidue.ltl.evaluation.measures.regression.MeanSquaredError)3 File (java.io.File)2 EvaluationData (de.unidue.ltl.evaluation.core.EvaluationData)1 Accuracy (de.unidue.ltl.evaluation.measures.Accuracy)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 RSquared (de.unidue.ltl.evaluation.measures.regression.RSquared)1 HashMap (java.util.HashMap)1