40 lines
1.1 KiB
Java
Raw Normal View History

2019-06-20 13:17:23 +02:00
package machine_learning.perceptron;
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()
{
2019-06-23 13:48:53 +02:00
double biasUnit = 1d;
2019-06-20 13:17:23 +02:00
this.positives = new ArrayList<>(List.of(
2019-06-23 13:48:53 +02:00
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)))
2019-06-20 13:17:23 +02:00
);
this.negatives = new ArrayList<>(List.of(
2019-06-23 13:48:53 +02:00
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)))
2019-06-20 13:17:23 +02:00
);
}
@Test
void shouldClassifyCorrect()
{
new Perceptron().learn(this.positives, this.negatives);
}
}