Skip to content
Snippets Groups Projects
Commit ec115e8b authored by a.croix's avatar a.croix
Browse files

Fix

parent a41f9ece
No related branches found
No related tags found
No related merge requests found
# 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)
[![Maven Central](https://img.shields.io/maven-central/v/be.cylab/java-wowa-training.svg)](https://mvnrepository.com/artifact/be.cylab/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)
[![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>
<groupId>be.cylab</groupId>
<artifactId>java-wowa-training</artifactId>
<version>0.0.3</version>
</dependency>
```
https://mvnrepository.com/artifact/be.cylab/java-wowa-training
## Usage
```
<dependency>
<groupId>be.cylab</groupId>
<artifactId>java-wowa-training</artifactId>
<version>0.0.3</version>
</dependency>
```
https://mvnrepository.com/artifact/be.cylab/java-wowa-training
## Usage
``` java
public static void main(String[] args) {
Logger logger = Logger.getLogger(Trainer.class.getName());
logger.setLevel(Level.INFO);
int population_size = 100;
int crossover_rate = 60;
int mutation_rate = 10;
int selection_method = TrainerParameters.SELECTION_METHOD_RWS;
int max_generation = 110;
TrainerParameters parameters = new TrainerParameters(logger, population_size,
crossover_rate, mutation_rate, selection_method, max_generation);
Trainer trainer = new Trainer(parameters);
//Input data
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.8, 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.5, 0.1, 0.2, 0.3});
data.add(new double[] {0.1, 0.1, 0.1, 0.1});
//Expected aggregated value for each data vector
double[] expected = new double[] {0.1, 0.2, 0.3, 0.4, 0.5, 0.6};
SolutionDistance solution = trainer.run(data, expected);
//Display solution
System.out.println(solution);
}
```
The example above will produce something like:
```
SolutionDistance{
weights_w=[0.1403303611048977, 0.416828569516884, 0.12511121306189063, 0.1872211165629538, 0.1305087298401635],
weights_p=[0.0123494228072248, 0.10583088288437666, 0.5459452827654444, 0.17470250892324257, 0.1611718492107217],
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
- **populationSize** : size of the population in the algorithm. Suggested value : 100
- **crossoverRate** : defines the percentage of elements in each population used to generate the next population. Must be between 1 and 100. Suggested value : 60
- **mutationRate** : define the probability of random element change in the population. Must be between 1 and 100. Suggested value : 15
- **selectionMethod** : 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.
- **maxGeneration** : Determine the maximum number of iteration of the algorithm.
## References
- [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).
``` java
public static void main(String[] args) {
Logger logger = Logger.getLogger(Trainer.class.getName());
logger.setLevel(Level.INFO);
int population_size = 100;
int crossover_rate = 60;
int mutation_rate = 10;
int selection_method = TrainerParameters.SELECTION_METHOD_RWS;
int max_generation = 110;
TrainerParameters parameters = new TrainerParameters(logger, population_size,
crossover_rate, mutation_rate, selection_method, max_generation);
Trainer trainer = new Trainer(parameters);
//Input data
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.8, 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.5, 0.1, 0.2, 0.3});
data.add(new double[] {0.1, 0.1, 0.1, 0.1});
//Expected aggregated value for each data vector
double[] expected = new double[] {0.1, 0.2, 0.3, 0.4, 0.5, 0.6};
SolutionDistance solution = trainer.run(data, expected);
//Display solution
System.out.println(solution);
}
```
The example above will produce something like:
```
SolutionDistance{
weights_w=[0.1403303611048977, 0.416828569516884, 0.12511121306189063, 0.1872211165629538, 0.1305087298401635],
weights_p=[0.0123494228072248, 0.10583088288437666, 0.5459452827654444, 0.17470250892324257, 0.1611718492107217],
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
- **populationSize** : size of the population in the algorithm. Suggested value : 100
- **crossoverRate** : defines the percentage of elements in each population used to generate the next population. Must be between 1 and 100. Suggested value : 60
- **mutationRate** : define the probability of random element change in the population. Must be between 1 and 100. Suggested value : 15
- **selectionMethod** : 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.
- **maxGeneration** : Determine the maximum number of iteration of the algorithm.
## References
- [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