Created
January 8, 2019 17:20
-
-
Save fabiothiroki/d1531160163f60f99067ba979df7f383 to your computer and use it in GitHub Desktop.
knnTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.com.quintoandar.classifier; | |
import lombok.val; | |
import net.sf.javaml.core.Dataset; | |
import net.sf.javaml.core.DefaultDataset; | |
import net.sf.javaml.core.Instance; | |
import net.sf.javaml.distance.CosineDistance; | |
import net.sf.javaml.tools.InstanceTools; | |
import org.junit.Test; | |
public class ClassifierTest { | |
@Test | |
public void test() { | |
Dataset data = new DefaultDataset(); | |
for (int i = 0; i < 10000; i++) { | |
Instance tmpInstance = InstanceTools.randomInstance(64); | |
data.add(tmpInstance); | |
} | |
Instance testInstance = InstanceTools.randomInstance(64); | |
val result = data.kNearest(5, testInstance, new CosineDistance()); | |
System.out.println(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment