make sure we can score rows without a result already present @throws Exception
()
| 178 | * @throws Exception |
| 179 | */ |
| 180 | @Test |
| 181 | public void testTestScore() throws Exception { |
| 182 | final File tmpDir = File.createTempFile("FJunit_",".dir"); |
| 183 | tmpDir.delete(); |
| 184 | tmpDir.mkdirs(); |
| 185 | final File trainFile = new File(tmpDir,"uciCarTrain.tsv"); |
| 186 | final File testFile = new File(tmpDir,"uciCarTest2.tsv"); |
| 187 | final File modelFile = new File(tmpDir,"model.ser"); |
| 188 | final File resultFile = new File(tmpDir,"scored.tsv"); |
| 189 | TestLRPath.copyResourceToFile("com/winvector/logistic/uciCarTrain.tsv",trainFile); |
| 190 | TestLRPath.copyResourceToFile("com/winvector/logistic/uciCarTest2.tsv",testFile); |
| 191 | final TrivialReader trainSource = new TrivialReader(trainFile.toURI(),'\t',null,false,null, false); |
| 192 | final TrivialReader testSource = new TrivialReader(testFile.toURI(),'\t',null,false,null, false); |
| 193 | (new LogisticTrain()).run(trainSource,new Formula("rating ~ buying + maintenance + doors + persons + lug_boot + safety"),null, |
| 194 | modelFile,null); |
| 195 | final ObjectInputStream ois = new ObjectInputStream(new FileInputStream(modelFile)); |
| 196 | final Model model = (Model)ois.readObject(); |
| 197 | ois.close(); |
| 198 | LogisticScore.score(model,testSource,resultFile); |
| 199 | assertTrue(resultFile.length()>=50000); // confirm we wrote some rows |
| 200 | // clean up |
| 201 | modelFile.delete(); |
| 202 | trainFile.delete(); |
| 203 | testFile.delete(); |
| 204 | resultFile.delete(); |
| 205 | tmpDir.delete(); |
| 206 | } |
| 207 | } |
nothing calls this directly
no test coverage detected