Added script to pull historical stock data and resulting data files (1 per company). Added code to generate average price change per 1, 2 and 3-gram. Added code to output average price change per headline for VALIDATION dataset.
This commit is contained in:
@@ -1,21 +1,23 @@
|
||||
package net.woodyfolsom.cs6601.p3.dao;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import net.woodyfolsom.cs6601.p3.svc.HeadlineService;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.context.support.FileSystemXmlApplicationContext;
|
||||
|
||||
public class MySQLHeadlineDaoImplTest {
|
||||
private static HeadlineService headlineSvc;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
ApplicationContext context=new ClassPathXmlApplicationContext(new String[]{"/AppContext.xml"});
|
||||
ApplicationContext context=new FileSystemXmlApplicationContext(new String[]{"AppContext.xml"});
|
||||
headlineSvc = (HeadlineService) context
|
||||
.getBean("mySQLHeadlineSvc");
|
||||
}
|
||||
@@ -24,4 +26,29 @@ public class MySQLHeadlineDaoImplTest {
|
||||
public void testSelect() {
|
||||
assertNotNull(headlineSvc);
|
||||
}
|
||||
|
||||
//Change this back to @Test to run it... but beware, it shuffles the datasets. Best done n times for n-fold cross validation.
|
||||
@Ignore
|
||||
public void testAssignRandomDatasets() {
|
||||
|
||||
int trainingPct = 80;
|
||||
int testPct = 10;
|
||||
int valPct = 10;
|
||||
|
||||
//assignment fails if character is ommitted from valPct (80% 10% 1% by accident)
|
||||
assertFalse(headlineSvc.assignRandomDatasets(trainingPct,testPct,valPct/10));
|
||||
//assignment succeeds if requested ratio is 8-1-1
|
||||
assertTrue(headlineSvc.assignRandomDatasets(trainingPct,testPct,valPct));
|
||||
|
||||
int allCount = headlineSvc.getCount();
|
||||
int trainingCount = headlineSvc.getCount(1);
|
||||
int testCount = headlineSvc.getCount(2);
|
||||
int valCount = headlineSvc.getCount(3);
|
||||
|
||||
assertEquals(trainingCount + testCount + valCount, allCount);
|
||||
|
||||
assertEquals((double)trainingCount/allCount,(double)trainingPct / 100.0,0.01);
|
||||
assertEquals((double)testCount/allCount,(double)testPct / 100.0,0.01);
|
||||
assertEquals((double)valCount/allCount,(double)valPct / 100.0,0.01);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user