diff options
author | Nick Nussbaum <nick.nussbaum@fticonsulting.com> | 2012-12-28 23:40:57 +0400 |
---|---|---|
committer | Nick Nussbaum <nick.nussbaum@fticonsulting.com> | 2012-12-28 23:40:57 +0400 |
commit | 00251017b5b15c7b8f087f9fbbbf8eba8b06feed (patch) | |
tree | 3039d18b93acdb3730fd007fc257c9432810f0ec /cs_test/Program.cs | |
parent | 941bae3207bc4476a77c54a7af9f1e095f9542e6 (diff) |
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.
Diffstat (limited to 'cs_test/Program.cs')
-rw-r--r-- | cs_test/Program.cs | 41 |
1 files changed, 25 insertions, 16 deletions
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 + } } |