blob: 05b6ae61dc395e9c019dd6ab73eeacdeb0b1b674 (
plain)
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
27
28
29
30
31
32
33
34
35
36
|
package vw;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
/**
* Created by jmorra on 11/24/14.
*/
public class VWScorerTest {
private static VWScorer scorer;
@BeforeClass
public static void setup() throws IOException, InterruptedException {
// Since we want this test to continue to work between VW changes, we can't store the model
// Instead, we'll make a new model for each test
String vwModel = "target/house.model";
Runtime.getRuntime().exec("../vowpalwabbit/vw -d src/test/resources/house.vw -f " + vwModel).waitFor();
scorer = new VWScorer("--quiet -t -i " + vwModel);
}
@Test
public void testBlank() {
float prediction = scorer.getPrediction("| ");
assertEquals(0.075, prediction, 0.001);
}
@Test
public void testLine() {
float prediction = scorer.getPrediction("| price:0.23 sqft:0.25 age:0.05 2006");
assertEquals(0.118, prediction, 0.001);
}
}
|