Search in sources :

Example 1 with EvaluationEntry

use of de.unidue.ltl.evaluation.core.EvaluationEntry in project dkpro-tc by dkpro.

the class ScatterplotReport method execute.

@Override
public void execute() throws Exception {
    for (TaskContextMetadata subcontext : getSubtasks()) {
        if (TcTaskTypeUtil.isCrossValidationTask(getContext().getStorageService(), subcontext.getId())) {
            File id2outcomeFile = getContext().getStorageService().locateKey(subcontext.getId(), Constants.FILE_COMBINED_ID_OUTCOME_KEY);
            EvaluationData<Double> data = Tc2LtlabEvalConverter.convertRegressionModeId2Outcome(id2outcomeFile);
            double[] gold = new double[(int) data.size()];
            double[] prediction = new double[(int) data.size()];
            Iterator<EvaluationEntry<Double>> iterator = data.iterator();
            int i = 0;
            while (iterator.hasNext()) {
                EvaluationEntry<Double> next = iterator.next();
                gold[i] = next.getGold();
                prediction[i] = next.getPredicted();
                i++;
            }
            ScatterplotRenderer renderer = new ScatterplotRenderer(gold, prediction);
            getContext().storeBinary("scatterplot.pdf", renderer);
        } else if (TcTaskTypeUtil.isMachineLearningAdapterTask(getContext().getStorageService(), subcontext.getId())) {
            File id2outcomeFile = getContext().getStorageService().locateKey(subcontext.getId(), Constants.ID_OUTCOME_KEY);
            EvaluationData<Double> data = Tc2LtlabEvalConverter.convertRegressionModeId2Outcome(id2outcomeFile);
            double[] gold = new double[(int) data.size()];
            double[] prediction = new double[(int) data.size()];
            Iterator<EvaluationEntry<Double>> iterator = data.iterator();
            int i = 0;
            while (iterator.hasNext()) {
                EvaluationEntry<Double> next = iterator.next();
                gold[i] = next.getGold();
                prediction[i] = next.getPredicted();
                i++;
            }
            ScatterplotRenderer renderer = new ScatterplotRenderer(gold, prediction);
            getContext().storeBinary("scatterplot.pdf", renderer);
        }
    }
}
Also used : TaskContextMetadata(org.dkpro.lab.task.TaskContextMetadata) EvaluationEntry(de.unidue.ltl.evaluation.core.EvaluationEntry) EvaluationData(de.unidue.ltl.evaluation.core.EvaluationData) Iterator(java.util.Iterator) File(java.io.File) ScatterplotRenderer(org.dkpro.tc.ml.report.util.ScatterplotRenderer)

Aggregations

EvaluationData (de.unidue.ltl.evaluation.core.EvaluationData)1 EvaluationEntry (de.unidue.ltl.evaluation.core.EvaluationEntry)1 File (java.io.File)1 Iterator (java.util.Iterator)1 TaskContextMetadata (org.dkpro.lab.task.TaskContextMetadata)1 ScatterplotRenderer (org.dkpro.tc.ml.report.util.ScatterplotRenderer)1