From 00251017b5b15c7b8f087f9fbbbf8eba8b06feed Mon Sep 17 00:00:00 2001 From: Nick Nussbaum Date: Fri, 28 Dec 2012 11:40:57 -0800 Subject: adding a .bat test which invokes test 1 with the windows build of vw minor tweaks to the program cs_test version to align with the .bat test output. --- cs_test/Program.cs | 41 +++++++++++++++++++++++++---------------- test/test_1_winvw.bat | 2 ++ 2 files changed, 27 insertions(+), 16 deletions(-) create mode 100644 test/test_1_winvw.bat diff --git a/cs_test/Program.cs b/cs_test/Program.cs index 48b02c58..ab8f06e7 100644 --- a/cs_test/Program.cs +++ b/cs_test/Program.cs @@ -66,23 +66,28 @@ namespace cs_test } - - static public void RunMultiPassTest() { - + const string testDir = ".\\..\\..\\..\\..\\test\\"; - const string outDir = ".\\..\\..\\..\\..\\test\\"; // or make separate output directory before running + const string outDir = ".\\..\\..\\..\\..\\test\\"; const string trainSet = testDir + "train-sets\\0001.dat"; const string testSet = testDir + "test-sets\\0001.dat"; - const string predictFile = outDir + "0001A.predict.tmp"; - const string cacheFile = outDir + "00001A.cache"; - const string modelFile = outDir + "00001A.model"; - - string initTrain = String.Format( - " -k -l 20 --initial_t 128000 --power_t 1 -f {1} --passes 8 --invariant --ngram 3 --skips 1 --cache_file {0} ", - cacheFile, modelFile); + const string predictFile = outDir + "0001B.predict.tmp"; + const string cacheFile = outDir + "0001B.cache.tmp"; + const string modelFile = outDir + "0001B.model.tmp"; + RunTrainTest(trainSet, cacheFile, modelFile); + RunPredictTest(testSet, modelFile, predictFile); + } + + + static public void RunTrainTest(string trainSet, string cacheFile, string modelFile) + { + + string initTrain = String.Format( + " -k -l 20 --initial_t 128000 --power_t 1 --passes 8 --invariant --ngram 3 --skips 1 --cache_file {0} -f {1} ", + cacheFile, modelFile); IntPtr vw = VowpalWabbitInterface.Initialize(initTrain); using (var sr = new StreamReader(trainSet)) { @@ -94,10 +99,14 @@ namespace cs_test VowpalWabbitInterface.FinishExample(vw, example); } } - VowpalWabbitInterface.Finish(vw); + VowpalWabbitInterface.Finish(vw); + } - string initPredict = String.Format(" --invariant -i {0}", modelFile); - vw = VowpalWabbitInterface.Initialize(initPredict); + static public void RunPredictTest(string testSet, string modelFile, string predictFile) + { + + string initPredict = String.Format(" -t --invariant -i {0} ", modelFile); + IntPtr vw = VowpalWabbitInterface.Initialize(initPredict); using (var sw = new StreamWriter(predictFile)) { var sr = new StreamReader(testSet); @@ -109,12 +118,11 @@ namespace cs_test IntPtr example = VowpalWabbitInterface.ReadExample(vw, line); float score = VowpalWabbitInterface.Learn(vw, example); VowpalWabbitInterface.FinishExample(vw, example); - sw.WriteLine("{0}", score); + sw.WriteLine(score.ToString("F6")); } sw.Flush(); } } - VowpalWabbitInterface.Finish(vw); } @@ -123,5 +131,6 @@ namespace cs_test + } } diff --git a/test/test_1_winvw.bat b/test/test_1_winvw.bat new file mode 100644 index 00000000..49dd30d1 --- /dev/null +++ b/test/test_1_winvw.bat @@ -0,0 +1,2 @@ +..\vowpalwabbit\x64\Debug\vw.exe -k -l 20 --initial_t 128000 --power_t 1 -d train-sets\0001.dat -f 0001A.model.tmp -c --passes 8 --invariant --ngram 3 --skips 1 +..\vowpalwabbit\x64\Debug\vw.exe -t -d test-sets\0001.dat -i 0001A.model.tmp --invariant --predictions 0001A.predict.tmp \ No newline at end of file -- cgit v1.2.3