This commit is contained in:
Gianpaolo Coro 2012-09-20 16:59:38 +00:00
parent af6ce8db2b
commit 88186cea22
11 changed files with 315 additions and 16 deletions

View File

@ -1,3 +1,2 @@
HSPEN=org.gcube.dataanalysis.ecoengine.models.ModelHSPEN
AQUAMAPSNN=org.gcube.dataanalysis.ecoengine.models.ModelAquamapsNN
AQUAMAPSNNNS=org.gcube.dataanalysis.ecoengine.models.ModelAquamapsNNNS
AQUAMAPSNN=org.gcube.dataanalysis.ecoengine.models.ModelAquamapsNN

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -51,9 +51,7 @@ public class DistributionQualityAnalysis extends DataAnalysis {
templates.add(TableTemplates.TESTSET);
List<TableTemplates> templatesOccurrences = new ArrayList<TableTemplates>();
templatesOccurrences.add(TableTemplates.OCCURRENCE_AQUAMAPS);
templatesOccurrences.add(TableTemplates.TRAININGSET);
templatesOccurrences.add(TableTemplates.TESTSET);
templatesOccurrences.add(TableTemplates.HCAF);
InputTable p1 = new InputTable(templatesOccurrences,"PositiveCasesTable","A Table containing positive cases");
InputTable p2 = new InputTable(templatesOccurrences,"NegativeCasesTable","A Table containing negative cases");

View File

@ -51,8 +51,8 @@ public class HabitatRepresentativeness extends DataAnalysis {
InputTable p1 = new InputTable(templates,"ProjectingAreaTable","A Table containing projecting area information");
PrimitiveType p2 = new PrimitiveType(String.class.getName(), null, PrimitiveTypes.STRING, "ProjectingAreaFeaturesOptionalCondition","optional filter for taking area rows","oceanarea>0",true);
InputTable p3 = new InputTable(templatesOccurrences,"PositiveCasesTable","A Table containing positive cases");
InputTable p4 = new InputTable(templatesOccurrences,"NegativeCasesTable","A Table containing negative cases");
InputTable p3 = new InputTable(templates,"PositiveCasesTable","A Table containing positive cases");
InputTable p4 = new InputTable(templates,"NegativeCasesTable","A Table containing negative cases");
// PrimitiveType p5 = new PrimitiveType(String.class.getName(), null, PrimitiveTypes.STRING, "FeaturesColumns","fetures columns names separated by comma","depthmean,depthmax,depthmin, sstanmean,sbtanmean,salinitymean,salinitybmean, primprodmean,iceconann,landdist,oceanarea");
ColumnTypesList p5 = new ColumnTypesList ("PositiveCasesTable","FeaturesColumns", "Features columns", false);
@ -230,6 +230,7 @@ public class HabitatRepresentativeness extends DataAnalysis {
AnalysisLogger.getLogger().error("ALERT: AN ERROR OCCURRED DURING HRS CALCULATION : " + e.getLocalizedMessage());
throw e;
} finally {
status=100;
AnalysisLogger.getLogger().trace("COMPUTATION FINISHED ");
}
}

View File

@ -185,7 +185,7 @@ public class Neural_Network implements Serializable {
return prop(input, 0);
else
System.out.println("Errore:numero di input non valido! ");
System.out.println("Error : number of inputs not valid!");
return null;
}
@ -225,7 +225,7 @@ public class Neural_Network implements Serializable {
arrayout[i + 1] = trainprop(arrayout[i], i);
return arrayout;
} else
System.out.println("Errore:numero di input non valido! ");
System.out.println("Error : number of inputs not valid!");
return null;
}
@ -308,7 +308,7 @@ public class Neural_Network implements Serializable {
public void train(double[][] inputvet, double[][] correctoutputvet) {
if (griglia[griglia.length - 1].length != correctoutputvet[0].length)
System.out.println("Errore: il vettore degli output " + "NON ha una lunghezza pari " + "a quella dell'output " + "della rete");
System.out.println("Error : the vector of outputs has not a lenght equal to the output of the network");
else {
double en = 2;
int counter = 0;
@ -320,9 +320,7 @@ public class Neural_Network implements Serializable {
en += energy(this.propagate(inputvet[i]), correctoutputvet[i]);
}
System.out.println("errore: " + en);
System.out.println("Learning Score: " + en);
counter++;
}
System.out.println("Scarto Finale: " + en);

View File

@ -79,10 +79,10 @@ public class AquamapsNNSuitable extends AquamapsSuitable{
}
// 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

@ -44,7 +44,7 @@ public class ProduceTestMap {
String finalDistributionKeyColumn = "csquarecode";
// Train
// ModelerT.train(ModelerT.getTrainingConfig(modelName, absenceTable, presenceTable, speciesCode, userName, neuralNetworkLayers, configPath));
ModelerT.train(ModelerT.getTrainingConfig(modelName, absenceTable, presenceTable, speciesCode, userName, neuralNetworkLayers, configPath));
// Generate
GeneratorT.generate(GeneratorT.getGenerationConfig(numberOfResources, generatorName, envelopeTable, preprocessedTable, speciesCode, userName, csquareTable, finalDistributionTable, configPath));

View File

@ -0,0 +1,303 @@
package org.gcube.dataanalysis.ecoengine.test.experiments.latimeria;
import java.util.HashMap;
import java.util.List;
import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration;
import org.gcube.dataanalysis.ecoengine.datatypes.PrimitiveType;
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.processing.factories.EvaluatorsFactory;
import org.gcube.dataanalysis.ecoengine.processing.factories.GeneratorsFactory;
import org.gcube.dataanalysis.ecoengine.processing.factories.ModelersFactory;
import org.gcube.dataanalysis.ecoengine.test.regression.Regressor;
public class ExperimentsForLatimeria {
static String absenceRandom = "absence_data_latimeria_random";
static String absenceStatic = "absence_data_latimeria";
static String aquamapsSuitableTable = "hspec_suitable_latimeria_chalumnae";
static String aquamapsNativeTable = "hspec_native_latimeria_chalumnae";
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 staticsuitable = "staticsuitable";
static String randomsuitable = "randomsuitable";
static String staticnative = "staticnative";
static String randomnative = "randomnative";
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;
}
public static void generateAquamapsNativeSuitable() throws Exception{
List<Generator> generators = null;
generators = GeneratorsFactory.getGenerators(configAquamapsSuitable());
generators.get(0).init();
Regressor.process(generators.get(0));
generators = null;
generators = GeneratorsFactory.getGenerators(configAquamapsNative());
generators.get(0).init();
Regressor.process(generators.get(0));
generators = null;
}
public static void calcdiscrepancy(String table1,String table2) throws Exception{
List<Evaluator> evaluators = null;
evaluators = EvaluatorsFactory.getEvaluators(configDiscrepancyAnalysis(table1, table2));
evaluators.get(0).init();
Regressor.process(evaluators.get(0));
PrimitiveType output = (PrimitiveType) evaluators.get(0).getOutput();
HashMap<String, String> out = (HashMap<String, String>)output.getContent();
DiscrepancyAnalysis.visualizeResults(out);
evaluators = null;
}
public static void calcquality(String table1,String absenceTable) throws Exception{
List<Evaluator> evaluators = null;
evaluators = EvaluatorsFactory.getEvaluators(configQualityAnalysis(table1, absenceTable));
evaluators.get(0).init();
Regressor.process(evaluators.get(0));
PrimitiveType output = (PrimitiveType) evaluators.get(0).getOutput();
HashMap<String, String> out = (HashMap<String, String>)output.getContent();
DiscrepancyAnalysis.visualizeResults(out);
evaluators = null;
}
static String hcaf= "hcaf_d";
public static void calcHRS(String hcaf,String absenceTable) throws Exception{
List<Evaluator> evaluators = null;
evaluators = EvaluatorsFactory.getEvaluators(configHRSAnalysis(hcaf, absenceTable));
evaluators.get(0).init();
Regressor.process(evaluators.get(0));
PrimitiveType output = (PrimitiveType) evaluators.get(0).getOutput();
HashMap<String, String> out = (HashMap<String, String>)output.getContent();
DiscrepancyAnalysis.visualizeResults(out);
evaluators = null;
}
public static void main(String[] args) throws Exception{
// generateAquamapsNativeSuitable();
// trainNeuralNetworks();
// generateAquamapsNativeSuitableNeuralNetwokrs();
/*
calcdiscrepancy(aquamapsSuitableTable, nntablesuitable);
calcdiscrepancy(aquamapsSuitableTable, nntablesuitableRandom);
calcdiscrepancy(aquamapsNativeTable, nntablenative);
calcdiscrepancy(aquamapsNativeTable, nntablenativeRandom);
*/
/*
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);
}
}