2019-06-27 00:02:21 +02:00

41 lines
1.0 KiB
Java

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;
import java.util.ArrayList;
import java.util.List;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class PerceptronTest
{
List<Vector> positives;
List<Vector> negatives;
@BeforeAll
void initLearnData()
{
double biasUnit = 1d;
this.positives = new ArrayList<>(List.of(
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(6d, 1d, biasUnit),
new Vector(7d, 3d, biasUnit),
new Vector(8d, 2d, biasUnit),
new Vector(9d, 0d, biasUnit))
);
}
@Test
void shouldClassifyCorrect()
{
new Perceptron().learn(this.positives, this.negatives);
}
}