Menu

[572a65]: / src / junit / distance / CosineDistanceTest.java  Maximize  Restore  History

Download this file

27 lines (22 with data), 668 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
* %SVN.HEADER%
*/
package junit.distance;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import net.sf.javaml.core.DenseInstance;
import net.sf.javaml.core.Instance;
import net.sf.javaml.distance.CosineDistance;
import org.junit.Test;
public class CosineDistanceTest {
@Test
public void testCalculateDistance() {
double[]data={1,1,1};
double[]data2={0,2,4};
Instance a=new DenseInstance(data);
Instance b=new DenseInstance(data2);
CosineDistance cs=new CosineDistance();
assertEquals(cs.measure(a, a),0,0.00001);
assertTrue(cs.measure(a, b)>0);
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.