/** * Name: main Goal: example of JFuge's usage * * @param args: not used */ public static void main(String[] args) { Instances train_data = DataLoader.loadData( null, null, "/Users/numa/NUMA/Dossier Ecole/HEIG/Semestre 7/PDB/code/PDB_Trezzini/src/org/cheminfo/scripting/data/iris_train.arff", true, -1); Instances test_data = DataLoader.loadData( null, null, "/Users/numa/NUMA/Dossier Ecole/HEIG/Semestre 7/PDB/code/PDB_Trezzini/src/org/cheminfo/scripting/data/iris_test.arff", true, -1); double mutation_rate = 0.1; double crossover_rate = 0.2; double selection_rate = -1; int num_generations = 100; String selection_algorithm = TOURNAMENT_SELECTION; String error_algorithm = ERROR_MSE; double elitism_rate = 0.1; int tournament_size = 10; int pop = 200; double classification_weight = 1; double error_weight = 0; double rule_number_weight = 0; double var_per_rule_weight = 0.1; int rule_count = 5; FuzzySystem fs = null; double max = 0; for (int i = 0; i < 1; i++) { Coevolution ce = new Coevolution( train_data, mutation_rate, crossover_rate, selection_rate, pop, num_generations, false, selection_algorithm, error_algorithm, elitism_rate, tournament_size, classification_weight, error_weight, rule_number_weight, var_per_rule_weight, rule_count); FuzzySystem best = ce.evolveSystem(); System.out.println(best); if (best.getFitness() > max) { fs = best; max = best.getFitness(); } // System.out.println(best); System.out.println(i + ": " + best.getFitness()); } System.out.println(fs); System.out.println(max); double[] classif = fs.classifyInstances(test_data); double[][] distrib = fs.distributionForInstances(test_data); for (int i = 0; i < classif.length; i++) { System.out.println(classif[i]); } for (int i = 0; i < distrib.length; i++) { for (int j = 0; j < distrib[i].length; j++) { System.out.print(distrib[i][j] + " "); } System.out.println(); } } /*end main*/
/** * Name: classifyInstances Goal: classifies each instance of the given dataset according to the * predictions made by the fuzzy system * * @param test_data: the data to classify * @return double[]: the classification for each instance */ public double[] classifyInstances(Instances test_data) { double[] result = fs.classifyInstances(test_data); return result; } /*end distributionForInstance*/