From 54ba7bb3e59d7e08e161a2839ad2392186bb9f74 Mon Sep 17 00:00:00 2001 From: Gianpaolo Coro Date: Mon, 15 Oct 2012 15:14:28 +0000 Subject: [PATCH] git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngine@59733 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../evaluation/DiscrepancyAnalysis.java | 24 +++++++++++++++---- .../test/checks/TestDBNEXTEvaluators.java | 5 ++-- 2 files changed, 22 insertions(+), 7 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 ea132fa..b4d094a 100644 --- a/src/main/java/org/gcube/dataanalysis/ecoengine/evaluation/DiscrepancyAnalysis.java +++ b/src/main/java/org/gcube/dataanalysis/ecoengine/evaluation/DiscrepancyAnalysis.java @@ -90,6 +90,25 @@ public class DiscrepancyAnalysis extends DataAnalysis { maxCompElements = maxx!=0?maxx:Integer.MAX_VALUE; } + List takeNPoints = DatabaseFactory.executeSQLQuery(String.format(getNumberOfElementsQuery, FirstTable), connection); + List takeMPoints = DatabaseFactory.executeSQLQuery(String.format(getNumberOfElementsQuery, SecondTable), connection); + int nPoints = Integer.parseInt(""+takeNPoints.get(0)); + int mPoints = Integer.parseInt(""+takeMPoints.get(0)); + numberofvectors = Math.max(nPoints, mPoints); + + + if (FirstTable.equals(SecondTable)){ + output = new HashMap(); + output.put("MEAN", "0.0"); + output.put("VARIANCE", "0.0"); + output.put("NUMBER_OF_ERRORS", "0"); + output.put("NUMBER_OF_COMPARISONS", "" + numberofvectors); + output.put("ACCURACY", "100.0"); + output.put("MAXIMUM_ERROR", "-"); + output.put("MAXIMUM_ERROR_POINT", "-"); + return output; + } + // String query = String.format(discrepancyQuery, FirstTableCsquareColumn, SecondTableCsquareColumn, FirstTableProbabilityColumn, SecondTableProbabilityColumn, FirstTable, SecondTable); List nelementsQ = DatabaseFactory.executeSQLQuery(DatabaseUtils.countElementsStatement(FirstTable),connection); int nelements = Integer.parseInt(""+nelementsQ.get(0)); @@ -99,11 +118,6 @@ 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); - List takeNPoints = DatabaseFactory.executeSQLQuery(String.format(getNumberOfElementsQuery, FirstTable), connection); - List takeMPoints = DatabaseFactory.executeSQLQuery(String.format(getNumberOfElementsQuery, SecondTable), connection); - int nPoints = Integer.parseInt(""+takeNPoints.get(0)); - int mPoints = Integer.parseInt(""+takeMPoints.get(0)); - numberofvectors = Math.max(nPoints, mPoints); AnalysisLogger.getLogger().trace("Discrepancy Calculation - Query to perform :" + query); List takePoints = DatabaseFactory.executeSQLQuery(query, connection); diff --git a/src/main/java/org/gcube/dataanalysis/ecoengine/test/checks/TestDBNEXTEvaluators.java b/src/main/java/org/gcube/dataanalysis/ecoengine/test/checks/TestDBNEXTEvaluators.java index e8beb30..703af77 100644 --- a/src/main/java/org/gcube/dataanalysis/ecoengine/test/checks/TestDBNEXTEvaluators.java +++ b/src/main/java/org/gcube/dataanalysis/ecoengine/test/checks/TestDBNEXTEvaluators.java @@ -203,8 +203,9 @@ public static void main(String[] args) throws Exception { config.setNumberOfResources(1); config.setAgent("DISCREPANCY_ANALYSIS"); - config.setParam("FirstTable", "hspec_id_18b20d04_edf3_4c83_9a48_fcbe773e3fd3"); - config.setParam("SecondTable", "hspec_id_46cbfde4_9c9b_4414_a1f0_a350fe429018"); +// config.setParam("FirstTable", "hspec_id_686c508c_b64f_4ef9_9452_465465edbece"); + config.setParam("FirstTable", "hspec_id_bf4bb271_ed21_42cb_a2be_503979789055"); + config.setParam("SecondTable", "hspec_id_bf4bb271_ed21_42cb_a2be_503979789055"); config.setParam("FirstTableCsquareColumn", "csquarecode"); config.setParam("SecondTableCsquareColumn", "csquarecode");