static void RunPredictionEngineExample(PredictionEngineExample run, int n) { var feat = new float[] { 5, 1, 1, 1, 2, 1, 3, 1, 1 }; for (int i = 0; i < n; ++i) { feat[0] = i; run.Predict(feat); } }
public void TestTransform2ValueMapperMeasuringTime() { // It should be run with the profiler. #if (DEBUG) int n = 10; #else int n = 10000; #endif var name = FileHelper.GetTestFile("bc-lr.zip"); using (var example = new ValueMapperExample(name, "Features")) RunValueMapperExample(example, n); using (var engine = new PredictionEngineExample(name)) RunPredictionEngineExample(engine, n); }
public void TestTransform2ValueMapperSingleThreadSimple() { var name = FileHelper.GetTestFile("bc-lr.zip"); using (var example = new ValueMapperExample(name, "Features")) { var feat = new float[] { 5, 1, 1, 1, 2, 1, 3, 1, 1 }; var ans = example.Predict(feat); var ans2 = example.Predict(feat); if (ans != ans2) { throw new Exception(string.Format("Issue {0} != {1}", ans, ans2)); } using (var engine = new PredictionEngineExample(name)) { var ans6 = engine.Predict(feat); if (ans6.Item2 != ans2) { throw new Exception(string.Format("Issue {0} != {1}", ans, ans6.Item2)); } feat = new float[] { 5, 1, 1, 1, 2, -1, 3, 1, 1 }; ans = example.Predict(feat); ans2 = example.Predict(feat); if (ans != ans2) { throw new Exception(string.Format("Issue {0} != {1}", ans, ans2)); } ans6 = engine.Predict(feat); if (ans6.Item2 != ans) { throw new Exception(string.Format("Issue {0} != {1}", ans, ans6.Item2)); } } using (var exampleNo = new ValueMapperExample(name, "Features")) { var ans3 = example.Predict(feat); if (ans != ans3) { throw new Exception(string.Format("Issue {0} != {1}", ans, ans3)); } } } }