Refactored Perceptron
This commit is contained in:
parent
54cfe2dece
commit
05dba5bae5
@ -6,10 +6,12 @@ import java.util.List;
|
|||||||
|
|
||||||
public class Perceptron
|
public class Perceptron
|
||||||
{
|
{
|
||||||
|
private Vector weight;
|
||||||
|
|
||||||
public void learn(List<Vector> positives, List<Vector> negatives)
|
public void learn(List<Vector> positives, List<Vector> negatives)
|
||||||
{
|
{
|
||||||
var iterationCounter = 0;
|
var iterationCounter = 0;
|
||||||
var weight = this.getInitializationVector(positives, negatives);
|
this.weight = this.getInitializationVector(positives, negatives);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package machine_learning.perceptron;
|
package machine_learning.perceptron;
|
||||||
|
|
||||||
|
import machine_learning.Vector;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.TestInstance;
|
import org.junit.jupiter.api.TestInstance;
|
||||||
@ -18,17 +19,17 @@ class PerceptronTest
|
|||||||
{
|
{
|
||||||
double biasUnit = 1d;
|
double biasUnit = 1d;
|
||||||
this.positives = new ArrayList<>(List.of(
|
this.positives = new ArrayList<>(List.of(
|
||||||
new Vector(List.of(8d, 4d, biasUnit)),
|
new Vector(8d, 4d, biasUnit),
|
||||||
new Vector(List.of(8d, 6d, biasUnit)),
|
new Vector(8d, 6d, biasUnit),
|
||||||
new Vector(List.of(9d, 2d, biasUnit)),
|
new Vector(9d, 2d, biasUnit),
|
||||||
new Vector(List.of(9d, 5d, biasUnit)))
|
new Vector(9d, 5d, biasUnit))
|
||||||
);
|
);
|
||||||
|
|
||||||
this.negatives = new ArrayList<>(List.of(
|
this.negatives = new ArrayList<>(List.of(
|
||||||
new Vector(List.of(6d, 1d, biasUnit)),
|
new Vector(6d, 1d, biasUnit),
|
||||||
new Vector(List.of(7d, 3d, biasUnit)),
|
new Vector(7d, 3d, biasUnit),
|
||||||
new Vector(List.of(8d, 2d, biasUnit)),
|
new Vector(8d, 2d, biasUnit),
|
||||||
new Vector(List.of(9d, 0d, biasUnit)))
|
new Vector(9d, 0d, biasUnit))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user