This commit is contained in:
Gianpaolo Coro 2012-09-24 09:45:27 +00:00
parent 88186cea22
commit fb2cb3557b
14 changed files with 603518 additions and 225 deletions

602713
Analysis.log.1 Normal file

File diff suppressed because one or more lines are too long

View File

@ -2,6 +2,10 @@ BIOCLIMATE_HSPEC=org.gcube.dataanalysis.ecoengine.transducers.BioClimateHSPECTra
BIOCLIMATE_HCAF=org.gcube.dataanalysis.ecoengine.transducers.BioClimateHCAFTransducer
BIOCLIMATE_HSPEN=org.gcube.dataanalysis.ecoengine.transducers.BioClimateHSPENTransducer
HCAF_INTERPOLATION=org.gcube.dataanalysis.ecoengine.transducers.InterpolationTransducer
HCAF_FILTER=org.gcube.dataanalysis.ecoengine.transducers.simplequeryexecutors.HcafFilter
HSPEN_FILTER=org.gcube.dataanalysis.ecoengine.transducers.simplequeryexecutors.HspenFilter
ABSENCE_CELLS_FROM_AQUAMAPS=org.gcube.dataanalysis.ecoengine.transducers.simplequeryexecutors.MarineAbsencePointsFromAquamapsDistribution
PRESENCE_CELLS_GENERATION=org.gcube.dataanalysis.ecoengine.transducers.simplequeryexecutors.MarinePresencePoints
OCCURRENCES_MERGER=org.gcube.dataanalysis.ecoengine.transducers.OccurrencePointsMerger
OCCURRENCES_INTERSECTOR=org.gcube.dataanalysis.ecoengine.transducers.OccurrencePointsIntersector
OCCURRENCES_INSEAS_ONEARTH=org.gcube.dataanalysis.ecoengine.transducers.OccurrencePointsInSeaOnEarth

Binary file not shown.

Binary file not shown.

View File

@ -79,10 +79,10 @@ public class AquamapsNN extends AquamapsNative{
}
// double [] output = new double[1];
float probability = (float) output[0];
/*
if (probability>0.1)
AnalysisLogger.getLogger().debug(" Probability " + probability);
*/
// System.exit(0);
return probability;
}

View File

@ -9,236 +9,182 @@ import org.gcube.dataanalysis.ecoengine.evaluation.DiscrepancyAnalysis;
import org.gcube.dataanalysis.ecoengine.interfaces.Evaluator;
import org.gcube.dataanalysis.ecoengine.interfaces.Generator;
import org.gcube.dataanalysis.ecoengine.interfaces.Modeler;
import org.gcube.dataanalysis.ecoengine.interfaces.Transducerer;
import org.gcube.dataanalysis.ecoengine.processing.factories.EvaluatorsFactory;
import org.gcube.dataanalysis.ecoengine.processing.factories.GeneratorsFactory;
import org.gcube.dataanalysis.ecoengine.processing.factories.ModelersFactory;
import org.gcube.dataanalysis.ecoengine.processing.factories.TransducerersFactory;
import org.gcube.dataanalysis.ecoengine.test.regression.Regressor;
import org.gcube.dataanalysis.ecoengine.utils.PresetConfigGenerator;
public class ExperimentsForLatimeria {
static String absenceRandom = "absence_data_latimeria_random";
static String absenceStatic = "absence_data_latimeria";
static String absenceRandomTable = "absence_data_latimeria_random";
static String absenceStaticTable = "absence_data_latimeria";
static String presenceTable = "presence_data_latimeria";
static String envelopeTable = "hspen_latimeria";
static String aquamapsSuitableTable = "hspec_suitable_latimeria_chalumnae";
static String aquamapsNativeTable = "hspec_native_latimeria_chalumnae";
static String nnsuitableTable = "hspec_suitable_neural_latimeria_chalumnae";
static String nnsuitableRandomTable = "hspec_suitable_neural_latimeria_chalumnae_random";
static String nnnativeTable = "hspec_native_neural_latimeria_chalumnae";
static String nnnativeRandomTable = "hspec_native_neural_latimeria_chalumnae_random";
static String hcaf= "hcaf_d";
static String filteredhcaf= "bboxed_hcaf_d";
private static AlgorithmConfiguration configAquamapsSuitable() {
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(5);
config.setModel("AQUAMAPS_SUITABLE");
config.setParam("DistributionTable",aquamapsSuitableTable );
config.setParam("CsquarecodesTable", "hcaf_d");
config.setParam("EnvelopeTable", "hspen_latimeria");
config.setParam("OccurrencePointsTable", "occurrencecells");
config.setParam("CreateTable", "true");
return config;
}
private static AlgorithmConfiguration configAquamapsNative() {
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(5);
config.setModel("AQUAMAPS_NATIVE");
config.setParam("DistributionTable", aquamapsNativeTable);
config.setParam("CsquarecodesTable", "hcaf_d");
config.setParam("EnvelopeTable", "hspen_latimeria");
config.setParam("OccurrencePointsTable", "occurrencecells");
config.setParam("CreateTable", "true");
return config;
}
private static AlgorithmConfiguration configAquamapsNNSuitable(String tableName,String username) {
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(5);
config.setModel("AQUAMAPS_SUITABLE_NEURALNETWORK");
config.setParam("DistributionTable", tableName);
config.setParam("CsquarecodesTable", "hcaf_d");
config.setParam("EnvelopeTable", "hspen_latimeria");
config.setParam("OccurrencePointsTable", "occurrencecells");
config.setParam("CreateTable", "true");
config.setParam("SpeciesName", "Fis-30189");
config.setParam("UserName", username);
return config;
}
private static AlgorithmConfiguration configAquamapsNNNative(String tableName,String username) {
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(5);
config.setModel("AQUAMAPS_NATIVE_NEURALNETWORK");
config.setParam("DistributionTable", tableName);
config.setParam("CsquarecodesTable", "hcaf_d");
config.setParam("EnvelopeTable", "hspen_latimeria");
config.setParam("OccurrencePointsTable", "occurrencecells");
config.setParam("CreateTable", "true");
config.setParam("SpeciesName", "Fis-30189");
config.setParam("UserName", username);
return config;
}
public static AlgorithmConfiguration configSuitableNeuralNetworkTraining(String absenceTable,String username) {
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(5);
config.setModel("AQUAMAPSNN");
config.setParam("AbsenceDataTable", absenceTable);
config.setParam("PresenceDataTable", "presence_data_latimeria");
config.setParam("SpeciesName", "Fis-30189");
config.setParam("UserName",username);
config.setParam("LayersNeurons", "100"+AlgorithmConfiguration.getListSeparator()+"2");
return config;
}
public static AlgorithmConfiguration configNativeNeuralNetworkTraining(String absenceTable,String username) {
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(5);
config.setModel("AQUAMAPSNN");
config.setParam("AbsenceDataTable", absenceTable);
config.setParam("PresenceDataTable", "presence_data_latimeria");
config.setParam("SpeciesName", "Fis-30189");
config.setParam("UserName", username);
config.setParam("LayersNeurons", "100");
return config;
}
public static AlgorithmConfiguration configQualityAnalysis(String table,String absenceTable){
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(1);
config.setAgent("QUALITY_ANALYSIS");
config.setParam("PositiveCasesTable","presence_data_latimeria");
config.setParam("NegativeCasesTable",absenceTable);
config.setParam("PositiveCasesTableKeyColumn","csquarecode");
config.setParam("NegativeCasesTableKeyColumn","csquarecode");
config.setParam("DistributionTable",table);
config.setParam("DistributionTableKeyColumn","csquarecode");
config.setParam("DistributionTableProbabilityColumn","probability");
config.setParam("PositiveThreshold","0.8");
config.setParam("NegativeThreshold","0.3");
return config;
}
public static AlgorithmConfiguration configDiscrepancyAnalysis(String table1,String table2){
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(1);
config.setAgent("DISCREPANCY_ANALYSIS");
config.setParam("FirstTable",table1);
config.setParam("SecondTable",table2);
config.setParam("FirstTableCsquareColumn","csquarecode");
config.setParam("SecondTableCsquareColumn","csquarecode");
config.setParam("FirstTableProbabilityColumn","probability");
config.setParam("SecondTableProbabilityColumn","probability");
config.setParam("ComparisonThreshold","0.1");
return config;
}
public static AlgorithmConfiguration configHRSAnalysis(String projectiontable,String absenceTable){
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(1);
config.setAgent("HRS");
config.setParam("ProjectingAreaTable", projectiontable);
config.setParam("ProjectingAreaFeaturesOptionalCondition", "where oceanarea>0");
config.setParam("FeaturesColumns", "depthmean"+AlgorithmConfiguration.getListSeparator()+"depthmax"+AlgorithmConfiguration.getListSeparator()+"depthmin"+AlgorithmConfiguration.getListSeparator()+" sstanmean"+AlgorithmConfiguration.getListSeparator()+"sbtanmean"+AlgorithmConfiguration.getListSeparator()+"salinitymean"+AlgorithmConfiguration.getListSeparator()+"salinitybmean"+AlgorithmConfiguration.getListSeparator()+" primprodmean"+AlgorithmConfiguration.getListSeparator()+"iceconann"+AlgorithmConfiguration.getListSeparator()+"landdist"+AlgorithmConfiguration.getListSeparator()+"oceanarea");
config.setParam("PositiveCasesTable", "presence_data_latimeria");
config.setParam("NegativeCasesTable", absenceTable);
return config;
}
static String speciesID = "Fis-30189";
static String staticsuitable = "staticsuitable";
static String randomsuitable = "randomsuitable";
static String staticnative = "staticnative";
static String randomnative = "randomnative";
static int numberOfPoints = 34;
public static void trainNeuralNetworks() throws Exception{
List<Modeler> modelers = null;
modelers = ModelersFactory.getModelers(configSuitableNeuralNetworkTraining(absenceStatic,staticsuitable));
modelers.get(0).init();
Regressor.process(modelers.get(0));
modelers = null;
modelers = ModelersFactory.getModelers(configSuitableNeuralNetworkTraining(absenceRandom,randomsuitable));
modelers.get(0).init();
Regressor.process(modelers.get(0));
modelers = null;
modelers = ModelersFactory.getModelers(configNativeNeuralNetworkTraining(absenceStatic,staticnative));
modelers.get(0).init();
Regressor.process(modelers.get(0));
modelers = null;
modelers = ModelersFactory.getModelers(configNativeNeuralNetworkTraining(absenceRandom,randomnative));
modelers.get(0).init();
Regressor.process(modelers.get(0));
modelers = null;
}
static String nntablesuitable = "hspec_suitable_neural_latimeria_chalumnae";
static String nntablesuitableRandom = "hspec_suitable_neural_latimeria_chalumnae_random";
static String nntablenative = "hspec_native_neural_latimeria_chalumnae";
static String nntablenativeRandom = "hspec_native_neural_latimeria_chalumnae_random";
public static void generateAquamapsNativeSuitableNeuralNetwokrs() throws Exception{
List<Generator> generators = null;
generators = GeneratorsFactory.getGenerators(configAquamapsNNSuitable(nntablesuitable,staticsuitable));
generators.get(0).init();
Regressor.process(generators.get(0));
generators = null;
generators = GeneratorsFactory.getGenerators(configAquamapsNNSuitable(nntablesuitableRandom,randomsuitable));
generators.get(0).init();
Regressor.process(generators.get(0));
generators = null;
generators = GeneratorsFactory.getGenerators(configAquamapsNNNative(nntablenative,staticnative));
generators.get(0).init();
Regressor.process(generators.get(0));
generators = null;
generators = GeneratorsFactory.getGenerators(configAquamapsNNNative(nntablenativeRandom,randomnative));
generators.get(0).init();
Regressor.process(generators.get(0));
generators = null;
static float x1 = 95.346678f;
static float y1 = -9.18887f;
static float x2 = 125.668944f;
static float y2 = 12.983148f;
public static void generateHSPENTable() throws Exception{
System.out.println("*****************************HSPEN FILTER**********************************");
List<Transducerer> trans = null;
trans = TransducerersFactory.getTransducerers(PresetConfigGenerator.configHSPENfilter(envelopeTable, speciesID));
trans.get(0).init();
Regressor.process(trans.get(0));
trans = null;
}
public static void generateAquamapsNativeSuitable() throws Exception{
List<Generator> generators = null;
generators = GeneratorsFactory.getGenerators(configAquamapsSuitable());
System.out.println("*****************************AQUAMAPS SUITABLE**********************************");
generators = GeneratorsFactory.getGenerators(PresetConfigGenerator.configAquamapsSuitable(aquamapsSuitableTable,envelopeTable));
generators.get(0).init();
Regressor.process(generators.get(0));
generators = null;
generators = GeneratorsFactory.getGenerators(configAquamapsNative());
System.out.println("*****************************AQUAMAPS NATIVE**********************************");
generators = GeneratorsFactory.getGenerators(PresetConfigGenerator.configAquamapsNative(aquamapsNativeTable,envelopeTable));
generators.get(0).init();
Regressor.process(generators.get(0));
generators = null;
}
public static void generatePresenceTable() throws Exception{
System.out.println("*****************************PRESENCE TABLE**********************************");
List<Transducerer> trans = null;
trans = TransducerersFactory.getTransducerers(PresetConfigGenerator.configPresenceTable(presenceTable, -1, speciesID));
trans.get(0).init();
Regressor.process(trans.get(0));
trans = null;
}
public static void generateRandomAbsenceTable() throws Exception{
System.out.println("*****************************RANDOM ABSENCES**********************************");
List<Transducerer> trans = null;
trans = TransducerersFactory.getTransducerers(PresetConfigGenerator.configAbsenceTable(true, absenceRandomTable, aquamapsNativeTable, numberOfPoints, speciesID));
trans.get(0).init();
Regressor.process(trans.get(0));
trans = null;
}
public static void generateAbsenceTable() throws Exception{
System.out.println("*****************************ABSENCES**********************************");
List<Transducerer> trans = null;
trans = TransducerersFactory.getTransducerers(PresetConfigGenerator.configAbsenceTable(false, absenceStaticTable, aquamapsNativeTable, numberOfPoints, speciesID));
trans.get(0).init();
Regressor.process(trans.get(0));
trans = null;
}
public static void trainNeuralNetworks() throws Exception{
List<Modeler> modelers = null;
System.out.println("*****************************TRAINING NN SUITABLE WITH STATIC ABSENCES**********************************");
modelers = ModelersFactory.getModelers(PresetConfigGenerator.configSuitableNeuralNetworkTraining(presenceTable,absenceStaticTable,staticsuitable,speciesID,"100"+AlgorithmConfiguration.getListSeparator()+"2"));
modelers.get(0).init();
Regressor.process(modelers.get(0));
modelers = null;
/*
System.out.println("*****************************TRAINING NN SUITABLE WITH RANDOM ABSENCES**********************************");
modelers = ModelersFactory.getModelers(PresetConfigGenerator.configSuitableNeuralNetworkTraining(presenceTable,absenceRandomTable,staticsuitable,speciesID,"100"+AlgorithmConfiguration.getListSeparator()+"2"));
modelers.get(0).init();
Regressor.process(modelers.get(0));
modelers = null;
*/
System.out.println("*****************************TRAINING NN NATIVE WITH STATIC ABSENCES**********************************");
modelers = ModelersFactory.getModelers(PresetConfigGenerator.configNativeNeuralNetworkTraining(presenceTable,absenceStaticTable,staticnative,speciesID,"100"));
modelers.get(0).init();
Regressor.process(modelers.get(0));
modelers = null;
/*
System.out.println("*****************************TRAINING NN NATIVE WITH RANDOM ABSENCES**********************************");
modelers = ModelersFactory.getModelers(PresetConfigGenerator.configNativeNeuralNetworkTraining(presenceTable,absenceRandomTable,staticsuitable,speciesID,"100"));
modelers.get(0).init();
Regressor.process(modelers.get(0));
modelers = null;
*/
}
public static void trainSuitableNeuralNetworks() throws Exception{
List<Modeler> modelers = null;
System.out.println("*****************************TRAINING NN SUITABLE WITH STATIC ABSENCES**********************************");
modelers = ModelersFactory.getModelers(PresetConfigGenerator.configSuitableNeuralNetworkTraining(presenceTable,absenceStaticTable,staticsuitable,speciesID,"100"+AlgorithmConfiguration.getListSeparator()+"2"));
modelers.get(0).init();
Regressor.process(modelers.get(0));
modelers = null;
}
public static void trainNativeNeuralNetworks() throws Exception{
System.out.println("*****************************TRAINING NN NATIVE WITH STATIC ABSENCES**********************************");
List<Modeler> modelers = null;
modelers = ModelersFactory.getModelers(PresetConfigGenerator.configNativeNeuralNetworkTraining(presenceTable,absenceStaticTable,staticnative,speciesID,"100"+AlgorithmConfiguration.getListSeparator()+"2"));
modelers.get(0).init();
Regressor.process(modelers.get(0));
modelers = null;
}
public static void generateAquamapsNativeSuitableNeuralNetwokrs() throws Exception{
List<Generator> generators = null;
System.out.println("*****************************GENERATING NN SUITABLE WITH STATIC ABSENCES**********************************");
generators = GeneratorsFactory.getGenerators(PresetConfigGenerator.configAquamapsNNSuitable(nnsuitableTable,staticsuitable,envelopeTable,speciesID));
generators.get(0).init();
Regressor.process(generators.get(0));
generators = null;
/*
System.out.println("*****************************GENERATING NN SUITABLE WITH RANDOM ABSENCES**********************************");
generators = GeneratorsFactory.getGenerators(PresetConfigGenerator.configAquamapsNNSuitable(nnsuitableRandomTable,randomsuitable,envelopeTable,speciesID));
generators.get(0).init();
Regressor.process(generators.get(0));
generators = null;
*/
System.out.println("*****************************GENERATING NN NATIVE WITH STATIC ABSENCES**********************************");
generators = GeneratorsFactory.getGenerators(PresetConfigGenerator.configAquamapsNNNative(nnnativeTable,staticnative,envelopeTable,speciesID));
generators.get(0).init();
Regressor.process(generators.get(0));
generators = null;
/*
System.out.println("*****************************GENERATING NN NATIVE WITH RANDOM ABSENCES**********************************");
generators = GeneratorsFactory.getGenerators(PresetConfigGenerator.configAquamapsNNNative(nnnativeRandomTable,randomnative,envelopeTable,speciesID));
generators.get(0).init();
Regressor.process(generators.get(0));
generators = null;
*/
}
public static void calcdiscrepancy(String table1,String table2) throws Exception{
System.out.println("*****************************DISCREPANCY: "+table1+" vs "+table2+"************************************");
List<Evaluator> evaluators = null;
evaluators = EvaluatorsFactory.getEvaluators(configDiscrepancyAnalysis(table1, table2));
evaluators = EvaluatorsFactory.getEvaluators(PresetConfigGenerator.configDiscrepancyAnalysis(table1, table2));
evaluators.get(0).init();
Regressor.process(evaluators.get(0));
PrimitiveType output = (PrimitiveType) evaluators.get(0).getOutput();
@ -247,9 +193,10 @@ public class ExperimentsForLatimeria {
evaluators = null;
}
public static void calcquality(String table1,String absenceTable) throws Exception{
public static void calcquality(String table,String presenceTable, String absenceTable) throws Exception{
System.out.println("*****************************QUALITY: "+table+" vs "+presenceTable+" and "+absenceTable+"************************************");
List<Evaluator> evaluators = null;
evaluators = EvaluatorsFactory.getEvaluators(configQualityAnalysis(table1, absenceTable));
evaluators = EvaluatorsFactory.getEvaluators(PresetConfigGenerator.configQualityAnalysis(presenceTable,absenceTable,table));
evaluators.get(0).init();
Regressor.process(evaluators.get(0));
PrimitiveType output = (PrimitiveType) evaluators.get(0).getOutput();
@ -258,10 +205,20 @@ public class ExperimentsForLatimeria {
evaluators = null;
}
static String hcaf= "hcaf_d";
public static void generateHCAFFilter() throws Exception{
System.out.println("*****************************HCAF FILTER ON : "+x1+","+y1+","+x2+","+y2+"************************************");
List<Transducerer> trans = null;
trans = TransducerersFactory.getTransducerers(PresetConfigGenerator.configHCAFfilter(filteredhcaf, x1, y1, x2, y2));
trans.get(0).init();
Regressor.process(trans.get(0));
trans = null;
}
public static void calcHRS(String hcaf,String absenceTable) throws Exception{
System.out.println("*****************************HRS: "+absenceTable+","+presenceTable+" vs "+hcaf+"************************************");
List<Evaluator> evaluators = null;
evaluators = EvaluatorsFactory.getEvaluators(configHRSAnalysis(hcaf, absenceTable));
evaluators = EvaluatorsFactory.getEvaluators(PresetConfigGenerator.configHRSAnalysis(filteredhcaf, absenceTable, presenceTable));
evaluators.get(0).init();
Regressor.process(evaluators.get(0));
PrimitiveType output = (PrimitiveType) evaluators.get(0).getOutput();
@ -270,34 +227,77 @@ public class ExperimentsForLatimeria {
evaluators = null;
}
public static void main1(String[] args) throws Exception{
//generate hspen table for the species
generateHSPENTable();
//generate Aquamaps distributions
generateAquamapsNativeSuitable();
//generate presence and absence hcafs
generatePresenceTable();
generateAbsenceTable();
generateHCAFFilter();
// generateRandomAbsenceTable(); NOTE: in this case the randoms are equal to the static
//train the neural networks on these tables
trainNeuralNetworks();
//project the neural networks
generateAquamapsNativeSuitableNeuralNetwokrs();
//Analysis
calcdiscrepancy(aquamapsSuitableTable, nnsuitableTable);
// calcdiscrepancy(aquamapsSuitableTable, nnsuitableRandomTable);
calcdiscrepancy(aquamapsNativeTable, nnnativeTable);
// calcdiscrepancy(aquamapsNativeTable, nnnativeRandomTable);
calcquality(aquamapsSuitableTable, presenceTable, absenceStaticTable);
// calcquality(aquamapsSuitableTable, presenceTable, absenceRandomTable);
calcquality(nnsuitableTable, presenceTable, absenceStaticTable);
// calcquality(nnsuitableTable, presenceTable, absenceRandomTable);
calcquality(nnsuitableRandomTable, presenceTable, absenceStaticTable);
// calcquality(nnsuitableRandomTable, presenceTable, absenceRandomTable);
//filter the hcaf on Indonesia
calcHRS(filteredhcaf,absenceStaticTable);
// calcHRS(filteredhcaf,absenceRandomTable);
}
public static void main(String[] args) throws Exception{
//generate hspen table for the species
// generateHSPENTable();
//generate Aquamaps distributions
// generateAquamapsNativeSuitable();
// trainNeuralNetworks();
//generate presence and absence hcafs
// generatePresenceTable();
// generateAbsenceTable();
// generateHCAFFilter();
//train the neural networks on these tables
// trainSuitableNeuralNetworks();
// trainNativeNeuralNetworks();
//project the neural networks
// generateAquamapsNativeSuitableNeuralNetwokrs();
//Analysis
/*
calcdiscrepancy(aquamapsSuitableTable, nntablesuitable);
calcdiscrepancy(aquamapsSuitableTable, nntablesuitableRandom);
calcdiscrepancy(aquamapsNativeTable, nntablenative);
calcdiscrepancy(aquamapsNativeTable, nntablenativeRandom);
calcdiscrepancy(aquamapsSuitableTable, nnsuitableTable);
calcdiscrepancy(aquamapsNativeTable, nnnativeTable);
calcquality(aquamapsSuitableTable, presenceTable, absenceStaticTable);
calcquality(nnsuitableTable, presenceTable, absenceStaticTable);
calcHRS(filteredhcaf,absenceStaticTable);
calcHRS(filteredhcaf,null);
*/
calcquality(aquamapsNativeTable, presenceTable, absenceStaticTable);
calcquality(nnnativeTable, presenceTable, absenceStaticTable);
/*
calcquality(aquamapsSuitableTable, absenceStatic);
calcquality(aquamapsSuitableTable, absenceRandom);
calcquality(nntablesuitable, absenceStatic);
calcquality(nntablesuitable, absenceRandom);
calcquality(nntablesuitableRandom, absenceStatic);
calcquality(nntablesuitableRandom, absenceRandom);
calcquality(nntablenative, absenceStatic);
calcquality(nntablenative, absenceRandom);
calcquality(nntablenativeRandom, absenceStatic);
calcquality(nntablenativeRandom, absenceRandom);
*/
calcHRS(hcaf,absenceStatic);
calcHRS(hcaf,absenceRandom);
}
}

View File

@ -0,0 +1,105 @@
package org.gcube.dataanalysis.ecoengine.transducers;
import java.util.List;
import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
import org.gcube.contentmanagement.lexicalmatcher.utils.DatabaseFactory;
import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration;
import org.gcube.dataanalysis.ecoengine.configuration.INFRASTRUCTURE;
import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;
import org.gcube.dataanalysis.ecoengine.interfaces.Transducerer;
import org.gcube.dataanalysis.ecoengine.utils.DatabaseUtils;
import org.gcube.dataanalysis.ecoengine.utils.ResourceFactory;
import org.hibernate.SessionFactory;
//implements a creator of tables which simply executes a query
public class QueryExecutor implements Transducerer {
protected String query = "";
protected String finalTableName = "";
protected float status = 0;
protected AlgorithmConfiguration config;
@Override
public List<StatisticalType> getInputParameters() {
return null;
}
@Override
public String getResourceLoad() {
if ((status > 0) && (status < 100))
return ResourceFactory.getResources(100f);
else
return ResourceFactory.getResources(0f);
}
ResourceFactory resourceManager;
@Override
public String getResources() {
if (resourceManager == null)
resourceManager = new ResourceFactory();
return resourceManager.getResourceLoad(1);
}
@Override
public float getStatus() {
return status;
}
@Override
public INFRASTRUCTURE getInfrastructure() {
return INFRASTRUCTURE.LOCAL;
}
@Override
public StatisticalType getOutput() {
return null;
}
@Override
public void init() throws Exception {
}
@Override
public void setConfiguration(AlgorithmConfiguration config) {
this.config = config;
}
@Override
public void shutdown() {
}
@Override
public String getDescription() {
return null;
}
@Override
public void compute() throws Exception {
SessionFactory dbconnection = null;
try{
AnalysisLogger.getLogger().trace("Initializing DB Connection");
dbconnection = DatabaseUtils.initDBSession(config);
AnalysisLogger.getLogger().trace("Deleting Previous Table");
DatabaseFactory.executeSQLUpdate(DatabaseUtils.dropTableStatement(finalTableName), dbconnection);
AnalysisLogger.getLogger().trace("Deleted");
AnalysisLogger.getLogger().trace("Executing query: "+query);
DatabaseFactory.executeSQLUpdate(query, dbconnection);
AnalysisLogger.getLogger().trace("Executed!");
} catch (Exception e) {
throw e;
} finally {
if (dbconnection != null)
dbconnection.close();
status = 100;
AnalysisLogger.getLogger().trace("Processing Finished and db closed");
}
}
}

View File

@ -0,0 +1,72 @@
package org.gcube.dataanalysis.ecoengine.transducers.simplequeryexecutors;
import java.util.ArrayList;
import java.util.List;
import org.gcube.dataanalysis.ecoengine.datatypes.OutputTable;
import org.gcube.dataanalysis.ecoengine.datatypes.PrimitiveType;
import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;
import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.PrimitiveTypes;
import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.TableTemplates;
import org.gcube.dataanalysis.ecoengine.transducers.QueryExecutor;
public class HcafFilter extends QueryExecutor {
static String finalTable = "FINAL_TABLE_NAME";
static String bbx1 = "BOUNDING_BOX_LEFT_LOWER_LONG";
static String bbx2 = "BOUNDING_BOX_RIGHT_UPPER_LONG";
static String bby1 = "BOUNDING_BOX_LEFT_LOWER_LAT";
static String bby2 = "BOUNDING_BOX_RIGHT_UPPER_LAT";
String bbx1$;
String bbx2$;
String bby1$;
String bby2$;
String species;
@Override
public void init() throws Exception {
finalTableName = config.getParam(finalTable);
bbx1$ = config.getParam(bbx1);
bbx2$ = config.getParam(bbx2);
bby1$ = config.getParam(bby1);
bby2$ = config.getParam(bby2);
query = "select * into " + finalTableName + " from hcaf_d where (centerlat-0.25)>" + bby1$ + " and (centerlong-0.25)>" + bbx1$ + " and (centerlat+0.25)<" + bby2$ + " and (centerlong+0.25)<" + bbx2$;
}
@Override
public List<StatisticalType> getInputParameters() {
PrimitiveType p1 = new PrimitiveType(String.class.getName(), null, PrimitiveTypes.RANDOM, finalTable, "the name of the Filtered Hcaf", "hspen_filtered");
PrimitiveType p2 = new PrimitiveType(Float.class.getName(), null, PrimitiveTypes.NUMBER, bbx1, "the left lower longitude of the bounding box (range [-180,+180])", "0");
PrimitiveType p3 = new PrimitiveType(Float.class.getName(), null, PrimitiveTypes.NUMBER, bbx2, "the right upper longitude of the bounding box (range [-180,+180])", "0");
PrimitiveType p4 = new PrimitiveType(Float.class.getName(), null, PrimitiveTypes.NUMBER, bby1, "the left lower latitude of the bounding box (range [-90,+90])", "10");
PrimitiveType p5 = new PrimitiveType(Float.class.getName(), null, PrimitiveTypes.NUMBER, bby2, "the right upper latitude of the bounding box (range [-90,+90])", "10");
List<StatisticalType> parameters = new ArrayList<StatisticalType>();
parameters.add(p1);
parameters.add(p2);
parameters.add(p3);
parameters.add(p4);
parameters.add(p5);
return parameters;
}
@Override
public StatisticalType getOutput() {
List<TableTemplates> template = new ArrayList<TableTemplates>();
template.add(TableTemplates.HCAF);
return new OutputTable(template, finalTableName, finalTableName, "a HCAF table focusing on the selected Bounding Box");
}
@Override
public String getDescription() {
return "An algorithm producing a HCAF table on a selected Bounding Box";
}
}

View File

@ -0,0 +1,56 @@
package org.gcube.dataanalysis.ecoengine.transducers.simplequeryexecutors;
import java.util.ArrayList;
import java.util.List;
import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration;
import org.gcube.dataanalysis.ecoengine.datatypes.OutputTable;
import org.gcube.dataanalysis.ecoengine.datatypes.PrimitiveType;
import org.gcube.dataanalysis.ecoengine.datatypes.PrimitiveTypesList;
import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;
import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.PrimitiveTypes;
import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.TableTemplates;
import org.gcube.dataanalysis.ecoengine.transducers.QueryExecutor;
public class HspenFilter extends QueryExecutor {
static String finalTable = "FINAL_TABLE_NAME";
static String speciesCodes = "SPECIES_CODES";
String species;
@Override
public void init() throws Exception {
finalTableName = config.getParam(finalTable);
species = config.getParam(speciesCodes).replace(AlgorithmConfiguration.getListSeparator(), ",");
query = "select * into "+finalTableName+" from hspen where speciesid in ('"+species+"')";
}
@Override
public List<StatisticalType> getInputParameters() {
PrimitiveType p3 = new PrimitiveType(String.class.getName(), null, PrimitiveTypes.RANDOM, finalTable,"the name of the Filtered Hspen","hspen_filtered");
PrimitiveTypesList pl = new PrimitiveTypesList(PrimitiveTypes.STRING, speciesCodes, "A list of species codes (Fish Base Format) to take. E.g. Fis-30189", false);
List<StatisticalType> parameters = new ArrayList<StatisticalType>();
parameters.add(p3);
parameters.add(pl);
return parameters;
}
@Override
public StatisticalType getOutput() {
List<TableTemplates> template = new ArrayList<TableTemplates>();
template.add(TableTemplates.HCAF);
return new OutputTable(template, finalTableName, finalTableName, "a HSPEN table containing only selected species");
}
@Override
public String getDescription() {
return "An algorithm producing a HSPEN table with only some selected species";
}
}

View File

@ -0,0 +1,75 @@
package org.gcube.dataanalysis.ecoengine.transducers.simplequeryexecutors;
import java.util.ArrayList;
import java.util.List;
import org.gcube.dataanalysis.ecoengine.datatypes.InputTable;
import org.gcube.dataanalysis.ecoengine.datatypes.OutputTable;
import org.gcube.dataanalysis.ecoengine.datatypes.PrimitiveType;
import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;
import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.PrimitiveTypes;
import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.TableTemplates;
import org.gcube.dataanalysis.ecoengine.transducers.QueryExecutor;
public class MarineAbsencePointsFromAquamapsDistribution extends QueryExecutor {
static String doRandom = "RANDOM_TAKE";
static String AquamapsHSpecTable = "AQUAMAPS_HSPEC";
static String finalTable = "FINAL_TABLE_NAME";
static String numberOfPoints = "NUMBER_OF_POINTS";
static String speciesCode = "SPECIES_CODE";
String dorandom;
String aquamapsTable;
String nPoints;
String species;
@Override
public void init() throws Exception {
dorandom = config.getParam(doRandom);
finalTableName = config.getParam(finalTable);
aquamapsTable= config.getParam(AquamapsHSpecTable);
nPoints= config.getParam(numberOfPoints);
species = config.getParam(speciesCode);
String dorandom$ = "";
if (Boolean.parseBoolean(dorandom))
dorandom$="order by random()";
query = "select * into "+finalTableName+" from hcaf_d as a where a.csquarecode in (select csquarecode from "+aquamapsTable+" where probability<=0.2 and speciesid='"+species+"'"+dorandom$+" limit "+nPoints+") and oceanarea>0";
}
@Override
public List<StatisticalType> getInputParameters() {
List<TableTemplates> templateHspec = new ArrayList<TableTemplates>();
templateHspec.add(TableTemplates.HSPEC);
InputTable p1 = new InputTable(templateHspec,AquamapsHSpecTable,"an Aquamaps table from which to produce the absence points","hspec");
PrimitiveType p2 = new PrimitiveType(Boolean.class.getName(), null, PrimitiveTypes.BOOLEAN, doRandom, "a flag for taking points randomly (true) or close together (false)","true");
PrimitiveType p3 = new PrimitiveType(String.class.getName(), null, PrimitiveTypes.RANDOM, finalTable,"Name of the HCAF table to produce containing Absence Cells","absence_hcaf");
PrimitiveType p4 = new PrimitiveType(Integer.class.getName(), null, PrimitiveTypes.NUMBER, numberOfPoints,"Number of points to take","20");
PrimitiveType p5 = new PrimitiveType(String.class.getName(), null, PrimitiveTypes.STRING, speciesCode,"the species code according to the Fish-Base conventions","Fis-30189");
List<StatisticalType> parameters = new ArrayList<StatisticalType>();
parameters.add(p1);
parameters.add(p2);
parameters.add(p3);
parameters.add(p4);
parameters.add(p5);
return parameters;
}
@Override
public StatisticalType getOutput() {
List<TableTemplates> template = new ArrayList<TableTemplates>();
template.add(TableTemplates.HCAF);
return new OutputTable(template, finalTableName, finalTableName, "a HCAF table containing Absence Points cells");
}
@Override
public String getDescription() {
return "An algorithm producing cells and features (HCAF) for a species containing absense points taken by an Aquamaps Distribution";
}
}

View File

@ -0,0 +1,64 @@
package org.gcube.dataanalysis.ecoengine.transducers.simplequeryexecutors;
import java.util.ArrayList;
import java.util.List;
import org.gcube.dataanalysis.ecoengine.datatypes.OutputTable;
import org.gcube.dataanalysis.ecoengine.datatypes.PrimitiveType;
import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;
import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.PrimitiveTypes;
import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.TableTemplates;
import org.gcube.dataanalysis.ecoengine.transducers.QueryExecutor;
public class MarinePresencePoints extends QueryExecutor {
static String finalTable = "FINAL_TABLE_NAME";
static String numberOfPoints = "NUMBER_OF_POINTS";
static String speciesCode = "SPECIES_CODE";
String nPoints;
String species;
@Override
public void init() throws Exception {
finalTableName = config.getParam(finalTable);
nPoints= config.getParam(numberOfPoints);
species = config.getParam(speciesCode);
String points = "";
if (Integer.parseInt(nPoints)>0){
points = "limit "+nPoints;
}
query = "select * into "+finalTableName+" from hcaf_d where csquarecode in (select csquarecode from occurrencecells where speciesid = '"+species+"' "+points+")";
}
@Override
public List<StatisticalType> getInputParameters() {
PrimitiveType p3 = new PrimitiveType(String.class.getName(), null, PrimitiveTypes.RANDOM, finalTable,"Name of the HCAF table to produce containing Presence Cells","presence_hcaf");
PrimitiveType p4 = new PrimitiveType(Integer.class.getName(), null, PrimitiveTypes.NUMBER, numberOfPoints,"Maximum number of points to take (-1 to take all)","-1");
PrimitiveType p5 = new PrimitiveType(String.class.getName(), null, PrimitiveTypes.STRING, speciesCode,"the species code according to the Fish-Base conventions","Fis-30189");
List<StatisticalType> parameters = new ArrayList<StatisticalType>();
parameters.add(p3);
parameters.add(p4);
parameters.add(p5);
return parameters;
}
@Override
public StatisticalType getOutput() {
List<TableTemplates> template = new ArrayList<TableTemplates>();
template.add(TableTemplates.HCAF);
return new OutputTable(template, finalTableName, finalTableName, "a HCAF table containing Presence Points cells");
}
@Override
public String getDescription() {
return "An algorithm producing cells and features (HCAF) for a species containing presence points";
}
}

View File

@ -0,0 +1,204 @@
package org.gcube.dataanalysis.ecoengine.utils;
import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration;
import org.gcube.dataanalysis.ecoengine.test.regression.Regressor;
public class PresetConfigGenerator {
public static AlgorithmConfiguration configAquamapsSuitable(String aquamapsSuitableTable, String envelopeTable) {
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(5);
config.setModel("AQUAMAPS_SUITABLE");
config.setParam("DistributionTable",aquamapsSuitableTable );
config.setParam("CsquarecodesTable", "hcaf_d");
config.setParam("EnvelopeTable", envelopeTable);
config.setParam("OccurrencePointsTable", "occurrencecells");
config.setParam("CreateTable", "true");
return config;
}
public static AlgorithmConfiguration configAquamapsNative(String aquamapsNativeTable, String envelopeTable) {
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(5);
config.setModel("AQUAMAPS_NATIVE");
config.setParam("DistributionTable", aquamapsNativeTable);
config.setParam("CsquarecodesTable", "hcaf_d");
config.setParam("EnvelopeTable", envelopeTable);
config.setParam("OccurrencePointsTable", "occurrencecells");
config.setParam("CreateTable", "true");
return config;
}
public static AlgorithmConfiguration configAquamapsNNSuitable(String tableName,String username, String envelopeTable, String speciesID) {
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(5);
config.setModel("AQUAMAPS_SUITABLE_NEURALNETWORK");
config.setParam("DistributionTable", tableName);
config.setParam("CsquarecodesTable", "hcaf_d");
config.setParam("EnvelopeTable", envelopeTable);
config.setParam("OccurrencePointsTable", "occurrencecells");
config.setParam("CreateTable", "true");
config.setParam("SpeciesName", speciesID);
config.setParam("UserName", username);
return config;
}
public static AlgorithmConfiguration configAquamapsNNNative(String tableName,String username, String envelopeTable, String speciesID) {
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(5);
config.setModel("AQUAMAPS_NATIVE_NEURALNETWORK");
config.setParam("DistributionTable", tableName);
config.setParam("CsquarecodesTable", "hcaf_d");
config.setParam("EnvelopeTable", envelopeTable);
config.setParam("OccurrencePointsTable", "occurrencecells");
config.setParam("CreateTable", "true");
config.setParam("SpeciesName", speciesID);
config.setParam("UserName", username);
return config;
}
public static AlgorithmConfiguration configSuitableNeuralNetworkTraining(String presenceTable, String absenceTable,String username, String speciesID, String neuronsAndLayers) {
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(5);
config.setModel("AQUAMAPSNN");
config.setParam("AbsenceDataTable", absenceTable);
config.setParam("PresenceDataTable", presenceTable);
config.setParam("SpeciesName", speciesID);
config.setParam("UserName",username);
config.setParam("LayersNeurons", neuronsAndLayers);
return config;
}
public static AlgorithmConfiguration configNativeNeuralNetworkTraining(String presenceTable, String absenceTable,String username, String speciesID, String neuronsAndLayers) {
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(5);
config.setModel("AQUAMAPSNN");
config.setParam("AbsenceDataTable", absenceTable);
config.setParam("PresenceDataTable", presenceTable);
config.setParam("SpeciesName", speciesID);
config.setParam("UserName", username);
config.setParam("LayersNeurons", neuronsAndLayers);
return config;
}
public static AlgorithmConfiguration configQualityAnalysis(String presenceTable, String absenceTable, String table){
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(1);
config.setAgent("QUALITY_ANALYSIS");
config.setParam("PositiveCasesTable",presenceTable);
config.setParam("NegativeCasesTable",absenceTable);
config.setParam("PositiveCasesTableKeyColumn","csquarecode");
config.setParam("NegativeCasesTableKeyColumn","csquarecode");
config.setParam("DistributionTable",table);
config.setParam("DistributionTableKeyColumn","csquarecode");
config.setParam("DistributionTableProbabilityColumn","probability");
config.setParam("PositiveThreshold","0.8");
config.setParam("NegativeThreshold","0.3");
return config;
}
public static AlgorithmConfiguration configDiscrepancyAnalysis(String table1,String table2){
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(1);
config.setAgent("DISCREPANCY_ANALYSIS");
config.setParam("FirstTable",table1);
config.setParam("SecondTable",table2);
config.setParam("FirstTableCsquareColumn","csquarecode");
config.setParam("SecondTableCsquareColumn","csquarecode");
config.setParam("FirstTableProbabilityColumn","probability");
config.setParam("SecondTableProbabilityColumn","probability");
config.setParam("ComparisonThreshold","0.1");
return config;
}
public static AlgorithmConfiguration configHRSAnalysis(String projectiontable,String absenceTable, String presenceTable){
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(1);
config.setAgent("HRS");
config.setParam("ProjectingAreaTable", projectiontable);
config.setParam("ProjectingAreaFeaturesOptionalCondition", "where oceanarea>0");
config.setParam("FeaturesColumns", "depthmean"+AlgorithmConfiguration.getListSeparator()+"depthmax"+AlgorithmConfiguration.getListSeparator()+"depthmin"+AlgorithmConfiguration.getListSeparator()+" sstanmean"+AlgorithmConfiguration.getListSeparator()+"sbtanmean"+AlgorithmConfiguration.getListSeparator()+"salinitymean"+AlgorithmConfiguration.getListSeparator()+"salinitybmean"+AlgorithmConfiguration.getListSeparator()+" primprodmean"+AlgorithmConfiguration.getListSeparator()+"iceconann"+AlgorithmConfiguration.getListSeparator()+"landdist"+AlgorithmConfiguration.getListSeparator()+"oceanarea");
config.setParam("PositiveCasesTable", presenceTable);
config.setParam("NegativeCasesTable", absenceTable);
return config;
}
public static AlgorithmConfiguration configAbsenceTable(boolean random, String absenceTable, String hspecTable, int numberOfPoints, String speciesCode){
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(1);
config.setAgent("ABSENCE_CELLS_FROM_AQUAMAPS");
config.setParam("RANDOM_TAKE", ""+random);
config.setParam("FINAL_TABLE_NAME", absenceTable);
config.setParam("AQUAMAPS_HSPEC", hspecTable);
config.setParam("SPECIES_CODE", speciesCode);
config.setParam("NUMBER_OF_POINTS", ""+numberOfPoints);
return config;
}
public static AlgorithmConfiguration configPresenceTable(String presenceTable, int numberOfPoints, String speciesCode){
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(1);
config.setAgent("PRESENCE_CELLS_GENERATION");
config.setParam("FINAL_TABLE_NAME", presenceTable);
config.setParam("SPECIES_CODE", speciesCode);
config.setParam("NUMBER_OF_POINTS", ""+numberOfPoints);
return config;
}
public static AlgorithmConfiguration configHCAFfilter(String table, float x1,float y1, float x2, float y2){
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(1);
config.setAgent("HCAF_FILTER");
config.setParam("FINAL_TABLE_NAME", table);
config.setParam("BOUNDING_BOX_LEFT_LOWER_LONG", ""+x1);
config.setParam("BOUNDING_BOX_RIGHT_UPPER_LONG", ""+x2);
config.setParam("BOUNDING_BOX_LEFT_LOWER_LAT", ""+y1);
config.setParam("BOUNDING_BOX_RIGHT_UPPER_LAT", ""+y2);
return config;
}
public static AlgorithmConfiguration configHSPENfilter(String table, String speciesList){
AlgorithmConfiguration config = Regressor.getConfig();
config.setNumberOfResources(1);
config.setAgent("HSPEN_FILTER");
config.setParam("FINAL_TABLE_NAME", table);
config.setParam("SPECIES_CODES", speciesList);
return config;
}
}