From d928073a6c4d9b5f99ea95420f7f08e917f6e057 Mon Sep 17 00:00:00 2001 From: Gianpaolo Coro Date: Mon, 3 Jun 2013 11:11:28 +0000 Subject: [PATCH] enhancement of the comparison query git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngine@76683 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../evaluation/DiscrepancyAnalysis.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/gcube/dataanalysis/ecoengine/evaluation/DiscrepancyAnalysis.java b/src/main/java/org/gcube/dataanalysis/ecoengine/evaluation/DiscrepancyAnalysis.java index ddb0659..b426841 100644 --- a/src/main/java/org/gcube/dataanalysis/ecoengine/evaluation/DiscrepancyAnalysis.java +++ b/src/main/java/org/gcube/dataanalysis/ecoengine/evaluation/DiscrepancyAnalysis.java @@ -22,11 +22,11 @@ public class DiscrepancyAnalysis extends DataAnalysis { // static String discrepancyQuery = "select distinct a.%1$s as csquareone,b.%2$s as csquaretwo,a.%3$s as firstprob,b.%4$s as secondprob from %5$s as a inner join %6$s as b on a.%1$s=b.%2$s and (a.%3$s<>b.%4$s)"; // static String discrepancyQuery = "select distinct a.%1$s as csquareone,b.%2$s as csquaretwo,a.%3$s as firstprob,b.%4$s as secondprob from (select * from %5$s order by %1$s limit %7$s) as a inner join (select * from %6$s order by %2$s limit %7$s) as b on a.%1$s=b.%2$s and (a.%3$s<>b.%4$s)"; - static String discrepancyQuery = "select distinct a.%1$s as csquareone,b.%2$s as csquaretwo,a.%3$s as firstprob,b.%4$s as secondprob from " + - "(select csquarecode,sum(%3$s) as %3$s from (select distinct * from %5$s order by %1$s limit %7$s) as aa group by %1$s) as a " + + static String discrepancyQuery = "select * from (select distinct a.%1$s as csquareone,b.%2$s as csquaretwo,a.%3$s as firstprob,b.%4$s as secondprob from " + + "(select %1$s , sum(%3$s) as %3$s from (select distinct * from %5$s order by %1$s limit %7$s) as aa group by %1$s) as a " + "left join " + - "(select csquarecode,sum(%4$s) as %4$s from (select distinct * from %6$s order by %2$s limit %7$s) as aa group by %2$s) as b " + - "on a.%1$s=b.%2$s and (a.%3$s<>b.%4$s)"; + "(select %2$s , sum(%4$s) as %4$s from (select distinct * from %6$s order by %2$s limit %7$s) as aa group by %2$s) as b " + + "on a.%1$s=b.%2$s) as sel where firstprob<>secondprob"; static String getNumberOfElementsQuery = "select count(*) from %1$s"; private static int minElements = 100; @@ -119,7 +119,7 @@ public class DiscrepancyAnalysis extends DataAnalysis { AnalysisLogger.getLogger().trace("Number Of Elements to take: "+nelements); String query = String.format(discrepancyQuery, FirstTableCsquareColumn, SecondTableCsquareColumn, FirstTableProbabilityColumn, SecondTableProbabilityColumn, FirstTable, SecondTable,""+nelements); - AnalysisLogger.getLogger().trace("Discrepancy Calculation - Query to perform :" + query); + AnalysisLogger.getLogger().debug("Discrepancy Calculation - Query to perform :" + query); List takePoints = DatabaseFactory.executeSQLQuery(query, connection); super.processedRecords = 0; @@ -144,6 +144,12 @@ public class DiscrepancyAnalysis extends DataAnalysis { output.put("ACCURACY", "" + MathFunctions.roundDecimal(accuracy,2)); output.put("MAXIMUM_ERROR", "" + MathFunctions.roundDecimal(maxerror,2)); output.put("MAXIMUM_ERROR_POINT", "" + maxdiscrepancyPoint); + if (numLower>numHigher) + output.put("TREND", "CONTRACTION"); + if (numLower points) { errors = new ArrayList(); @@ -189,6 +198,10 @@ public class DiscrepancyAnalysis extends DataAnalysis { maxerror = discrepancy; maxdiscrepancyPoint = csquare; } + if (probabilityPoint2>probabilityPoint1) + numHigher++; + if (probabilityPoint2