Refactored Perceptron

This commit is contained in:
Niklas Birk 2019-06-27 00:02:21 +02:00
parent 54cfe2dece
commit 05dba5bae5
2 changed files with 12 additions and 9 deletions

View File

@ -6,10 +6,12 @@ import java.util.List;
public class Perceptron
{
private Vector weight;
public void learn(List<Vector> positives, List<Vector> negatives)
{
var iterationCounter = 0;
var weight = this.getInitializationVector(positives, negatives);
this.weight = this.getInitializationVector(positives, negatives);
do
{

View File

@ -1,5 +1,6 @@
package machine_learning.perceptron;
import machine_learning.Vector;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
@ -18,17 +19,17 @@ class PerceptronTest
{
double biasUnit = 1d;
this.positives = new ArrayList<>(List.of(
new Vector(List.of(8d, 4d, biasUnit)),
new Vector(List.of(8d, 6d, biasUnit)),
new Vector(List.of(9d, 2d, biasUnit)),
new Vector(List.of(9d, 5d, biasUnit)))
new Vector(8d, 4d, biasUnit),
new Vector(8d, 6d, biasUnit),
new Vector(9d, 2d, biasUnit),
new Vector(9d, 5d, biasUnit))
);
this.negatives = new ArrayList<>(List.of(
new Vector(List.of(6d, 1d, biasUnit)),
new Vector(List.of(7d, 3d, biasUnit)),
new Vector(List.of(8d, 2d, biasUnit)),
new Vector(List.of(9d, 0d, biasUnit)))
new Vector(6d, 1d, biasUnit),
new Vector(7d, 3d, biasUnit),
new Vector(8d, 2d, biasUnit),
new Vector(9d, 0d, biasUnit))
);
}