Skip to content
Snippets Groups Projects
Commit c753457b authored by Tibo's avatar Tibo
Browse files

Fix README.md

parent e7697480
No related branches found
No related tags found
No related merge requests found
Pipeline #1365 passed
- # java-wowa-training # java-wowa-training
[![pipeline status](https://gitlab.cylab.be/cylab/java-wowa-training/badges/master/pipeline.svg)](https://gitlab.cylab.be/cylab/java-wowa-training/commits/master) [![pipeline status](https://gitlab.cylab.be/cylab/java-wowa-training/badges/master/pipeline.svg)](https://gitlab.cylab.be/cylab/java-wowa-training/commits/master)
[![Maven Central](https://img.shields.io/maven-central/v/be.cylab/java-wowa-training.svg)](https://mvnrepository.com/artifact/be.cylab/java-wowa-training) [![Maven Central](https://img.shields.io/maven-central/v/be.cylab/java-wowa-training.svg)](https://mvnrepository.com/artifact/be.cylab/java-wowa-training)
The WOWA operator (Torra) is a powerfull aggregation operator that allows to combine multiple input values into a single score. This is particulary interesting for detection and ranking systems that rely on multiple heuristics. The system can use WOWA to produce a single meaningfull score. The WOWA operator (Torra) is a powerfull aggregation operator that allows to combine multiple input values into a single score. This is particulary interesting for detection and ranking systems that rely on multiple heuristics. The system can use WOWA to produce a single meaningfull score.
A Java implementation of WOWA is available at [https://github.com/tdebatty/java-aggregation](https://github.com/tdebatty/java-aggregation). A Java implementation of WOWA is available at [https://github.com/tdebatty/java-aggregation](https://github.com/tdebatty/java-aggregation).
The WOWA operator requires two sets of parameters: p weights and w weights. In this project we use a genetic algorithm to compute the best values for p and w weights. For the training, the algorithm uses a dataset of input vectors together with the expected aggregated score of each vector. The WOWA operator requires two sets of parameters: p weights and w weights. In this project we use a genetic algorithm to compute the best values for p and w weights. For the training, the algorithm uses a dataset of input vectors together with the expected aggregated score of each vector.
This project is a Java implementation of the [PHP wowa-training](https://gitlab.cylab.be/cylab/wowa-training) project. This project is a Java implementation of the [PHP wowa-training](https://gitlab.cylab.be/cylab/wowa-training) project.
## Installation ## Installation
Using maven : Using maven :
``` ```
<dependency> <dependency>
<groupId>be.cylab</groupId> <groupId>be.cylab</groupId>
<artifactId>java-wowa-training</artifactId> <artifactId>java-wowa-training</artifactId>
<version>0.0.3</version> <version>0.0.3</version>
</dependency> </dependency>
```
```
https://mvnrepository.com/artifact/be.cylab/java-wowa-training https://mvnrepository.com/artifact/be.cylab/java-wowa-training
## Usage ## Usage
``` java ``` java
public static void main(String[] args) { public static void main(String[] args) {
Logger logger = Logger.getLogger(Trainer.class.getName()); Logger logger = Logger.getLogger(Trainer.class.getName());
logger.setLevel(Level.INFO); logger.setLevel(Level.INFO);
int population_size = 100; int population_size = 100;
int crossover_rate = 60; int crossover_rate = 60;
int mutation_rate = 10; int mutation_rate = 10;
int max_generation = 110; int max_generation = 110;
int selection_method = TrainerParameters.SELECTION_METHOD_RWS; int selection_method = TrainerParameters.SELECTION_METHOD_RWS;
int generation_population_method = TrainerParameters.POPULATION_INITIALIZATION_RANDOM; int generation_population_method = TrainerParameters.POPULATION_INITIALIZATION_RANDOM;
TrainerParameters parameters = new TrainerParameters(logger, population_size, TrainerParameters parameters = new TrainerParameters(logger, population_size,
crossover_rate, mutation_rate, max_generation, selection_method, generation_population_method); crossover_rate, mutation_rate, max_generation, selection_method, generation_population_method);
Trainer trainer = new Trainer(parameters); Trainer trainer = new Trainer(parameters);
//Input data //Input data
List<double[]> data = new ArrayList<double[]>(); List<double[]> data = new ArrayList<double[]>();
data.add(new double[] {0.1, 0.2, 0.3, 0.4}); data.add(new double[] {0.1, 0.2, 0.3, 0.4});
data.add(new double[] {0.1, 0.8, 0.3, 0.4}); data.add(new double[] {0.1, 0.8, 0.3, 0.4});
data.add(new double[] {0.2, 0.6, 0.3, 0.4}); data.add(new double[] {0.2, 0.6, 0.3, 0.4});
data.add(new double[] {0.1, 0.2, 0.5, 0.8}); data.add(new double[] {0.1, 0.2, 0.5, 0.8});
data.add(new double[] {0.5, 0.1, 0.2, 0.3}); data.add(new double[] {0.5, 0.1, 0.2, 0.3});
data.add(new double[] {0.1, 0.1, 0.1, 0.1}); data.add(new double[] {0.1, 0.1, 0.1, 0.1});
//Expected aggregated value for each data vector //Expected aggregated value for each data vector
double[] expected = new double[] {0.1, 0.2, 0.3, 0.4, 0.5, 0.6}; double[] expected = new double[] {0.1, 0.2, 0.3, 0.4, 0.5, 0.6};
SolutionDistance solution = trainer.run(data, expected); SolutionDistance solution = trainer.run(data, expected);
//Display solution //Display solution
System.out.println(solution); System.out.println(solution);
} }
``` ```
The example above will produce something like: The example above will produce something like:
```
SolutionDistance{ ```
SolutionDistance{
weights_w=[0.1403303611048977, 0.416828569516884, 0.12511121306189063, 0.1872211165629538, 0.1305087298401635], weights_w=[0.1403303611048977, 0.416828569516884, 0.12511121306189063, 0.1872211165629538, 0.1305087298401635],
weights_p=[0.0123494228072248, 0.10583088288437666, 0.5459452827654444, 0.17470250892324257, 0.1611718492107217], weights_p=[0.0123494228072248, 0.10583088288437666, 0.5459452827654444, 0.17470250892324257, 0.1611718492107217],
distance=8.114097675242476} distance=8.114097675242476}
``` ```
The **run** method returns a solution object, consisting of p weights and w weights to use with the WOWA operator, plus the total distance between the expected aggregated values that are given as parameter, and the aggregated values computed by WOWA using these weights.
### Parameters description
- **population_size** : size of the population in the algorithm. Suggested value : 100
- **crossover_rate** : defines the percentage of population generated by crossover. Must be between 1 and 100. Suggested value : 60
- **mutation_rate** : define the probability of random element change in the population. Must be between 1 and 100. Suggested value : 15
- **selection_method** : Determine the method used to select element in the population (for generate the next generation). SELECTION_METHOD_RWS for Roulette Wheel Selection and SELECTION_METHOD_TOS for Tournament Selection.
- **max_generation** : Determine the maximum number of iteration of the algorithm.
- **generation_population_method**: Determine the method used to generate the initial population. POPULATION_INITIALIZATION_RANDOM for a full random initialization and POPULATION_INITIALIZATION_QUASI_RANDOM for a population with specific elements.
## References The **run** method returns a solution object, consisting of p weights and w weights to use with the WOWA operator, plus the total distance between the expected aggregated values that are given as parameter, and the aggregated values computed by WOWA using these weights.
- [The WOWA operator : a review (V. Torra)](https://gitlab.cylab.be/cylab/wowa-training/raw/c3c3785c767ab8258df0fc585aec1e8d463851cd/doc/Torra%20-%202011%20-%20The%20WOWA%20Operator%20A%20Review.1007_978-3.pdf) ### Parameters description
- [Selection method for genetic algorithms (K. Jebari and M. Madiafi)](https://gitlab.cylab.be/cylab/wowa-training/raw/master/doc/SelectionMethodsForGA.pdf) - **population_size** : size of the population in the algorithm. Suggested value : 100
- **crossover_rate** : defines the percentage of population generated by crossover. Must be between 1 and 100. Suggested value : 60
- **mutation_rate** : define the probability of random element change in the population. Must be between 1 and 100. Suggested value : 15
- **selection_method** : Determine the method used to select element in the population (for generate the next generation). SELECTION_METHOD_RWS for Roulette Wheel Selection and SELECTION_METHOD_TOS for Tournament Selection.
- **max_generation** : Determine the maximum number of iteration of the algorithm.
- **generation_population_method**: Determine the method used to generate the initial population. POPULATION_INITIALIZATION_RANDOM for a full random initialization and POPULATION_INITIALIZATION_QUASI_RANDOM for a population with specific elements.
- [Continuous Genetic Algorithms (R. Haupt and S. Haupt)](https://gitlab.cylab.be/cylab/wowa-training/raw/master/doc/TheContinuousGeneticAlgorithm.pdf) ## References
- [A comparison of Active Set Method and genetic Algorithm approches for learning weighting vectors in some aggregation operators (D. Nettleton and V. Torra)](https://gitlab.cylab.be/cylab/wowa-training/raw/master/doc/A%20comparaison%20between%20Active%20Set%20Method%20and%20Genetic%20Algorithm%20for%20learning%20weights%20in%20aggregation%20operators.pdf). - [The WOWA operator : a review (V. Torra)](https://gitlab.cylab.be/cylab/wowa-training/raw/c3c3785c767ab8258df0fc585aec1e8d463851cd/doc/Torra%20-%202011%20-%20The%20WOWA%20Operator%20A%20Review.1007_978-3.pdf)
- [Selection method for genetic algorithms (K. Jebari and M. Madiafi)](https://gitlab.cylab.be/cylab/wowa-training/raw/master/doc/SelectionMethodsForGA.pdf)
- [Continuous Genetic Algorithms (R. Haupt and S. Haupt)](https://gitlab.cylab.be/cylab/wowa-training/raw/master/doc/TheContinuousGeneticAlgorithm.pdf)
- [A comparison of Active Set Method and genetic Algorithm approches for learning weighting vectors in some aggregation operators (D. Nettleton and V. Torra)](https://gitlab.cylab.be/cylab/wowa-training/raw/master/doc/A%20comparaison%20between%20Active%20Set%20Method%20and%20Genetic%20Algorithm%20for%20learning%20weights%20in%20aggregation%20operators.pdf).
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment