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

Change float usage in double + implementation of computeScoreTo function

parent 15534c3d
No related branches found
No related tags found
No related merge requests found
Pipeline #1007 failed
...@@ -24,6 +24,13 @@ ...@@ -24,6 +24,13 @@
<version>5.3.1</version> <version>5.3.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/info.debatty/java-aggregation -->
<dependency>
<groupId>info.debatty</groupId>
<artifactId>java-aggregation</artifactId>
<version>0.2</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
......
package be.cylab.java.wowa.training; package be.cylab.java.wowa.training;
import info.debatty.java.aggregation.WOWA;
public class SolutionDistance { public class SolutionDistance {
private double[] weights_w; private double[] weights_w;
private double[] weights_p; private double[] weights_p;
private double distance = Double.POSITIVE_INFINITY; private double distance = Double.POSITIVE_INFINITY;
public float computeScoreTo() { public void computeScoreTo(double[][] data, double[] expected) {
return 0; this.distance = 0;
for (int i = 0; i < data.length; i++) {
double[] vector = data[i];
double target_value = expected[i];
WOWA wowa = new WOWA(this.weights_w, this.weights_p);
double aggregated_value = wowa.aggregates(vector);
this.distance += Math.pow(target_value - aggregated_value, 2);
}
this.distance = Math.sqrt(this.distance);
} }
public void randomlyMutateWithProbability(float probability) { public void randomlyMutateWithProbability(double probability) {
} }
......
...@@ -8,7 +8,7 @@ public class Trainer { ...@@ -8,7 +8,7 @@ public class Trainer {
this.parameters = parameters; this.parameters = parameters;
} }
public SolutionDistance run(float[][] data, float[] expected) { public SolutionDistance run(double[][] data, double[] expected) {
} }
...@@ -24,7 +24,7 @@ public class Trainer { ...@@ -24,7 +24,7 @@ public class Trainer {
return 0; return 0;
} }
public SolutionDistance[] computeDistances(SolutionDistance[] solutions, float[][] data, float[] expected) { public SolutionDistance[] computeDistances(SolutionDistance[] solutions, double[][] data, double[] expected) {
} }
...@@ -56,7 +56,7 @@ public class Trainer { ...@@ -56,7 +56,7 @@ public class Trainer {
return this.parameters; return this.parameters;
} }
public SolutionDistance[] generateInitialPopulationAndComputeDistances(int populationSize, float[][] data, float[] expected) { public SolutionDistance[] generateInitialPopulationAndComputeDistances(int populationSize, double[][] data, double[] expected) {
} }
......
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