public void TestScaleResults() { const string smallValues = "predA=0.1 predB=0.2 A\n" + "predB=0.3 predA=0.1 B\n"; const string largeValues = "predA=10 predB=20 A\n" + "predB=30 predA=10 B\n"; const string smallTest = "predA=0.2 predB=0.2"; const string largeTest = "predA=20 predB=20"; var smallReader = new StringReader(smallValues); var smallEventStream = new RealBasicEventStream(new PlainTextByLineStream(smallReader)); var smallModel = GIS.TrainModel(100, new OnePassRealValueDataIndexer(smallEventStream, 0), false); var contexts = smallTest.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var values = RealValueFileEventStream.ParseContexts(contexts); var smallResults = smallModel.Eval(contexts, values); var smallResultString = smallModel.GetAllOutcomes(smallResults); Console.Out.WriteLine("smallResults: " + smallResultString); var largeReader = new StringReader(largeValues); var largeEventStream = new RealBasicEventStream(new PlainTextByLineStream(largeReader)); var largeModel = GIS.TrainModel(100, new OnePassRealValueDataIndexer(largeEventStream, 0), false); contexts = largeTest.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); values = RealValueFileEventStream.ParseContexts(contexts); var largeResults = largeModel.Eval(contexts, values); var largeResultString = smallModel.GetAllOutcomes(largeResults); Console.Out.WriteLine("largeResults: " + largeResultString); Assert.AreEqual(smallResults.Length, largeResults.Length); for (var i = 0; i < smallResults.Length; i++) { /* * System.out.println(string.format( * "classify with smallModel: %1$s = %2$f", smallModel.getOutcome(i), * smallResults[i])); * System.out.println(string.format( * "classify with largeModel: %1$s = %2$f", largeModel.getOutcome(i), * largeResults[i])); */ Assert.AreEqual(smallResults[i], largeResults[i], 0.01f); } }
public void TestScaleResults() { const string smallValues = "predA=0.1 predB=0.2 A\n" + "predB=0.3 predA=0.1 B\n"; const string largeValues = "predA=10 predB=20 A\n" + "predB=30 predA=10 B\n"; const string smallTest = "predA=0.2 predB=0.2"; const string largeTest = "predA=20 predB=20"; var smallReader = new StringReader(smallValues); var smallEventStream = new RealBasicEventStream(new PlainTextByLineStream(smallReader)); var smallModel = GIS.TrainModel(100, new OnePassRealValueDataIndexer(smallEventStream, 0), false); var contexts = smallTest.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); var values = RealValueFileEventStream.ParseContexts(contexts); var smallResults = smallModel.Eval(contexts, values); var smallResultString = smallModel.GetAllOutcomes(smallResults); Console.Out.WriteLine("smallResults: " + smallResultString); var largeReader = new StringReader(largeValues); var largeEventStream = new RealBasicEventStream(new PlainTextByLineStream(largeReader)); var largeModel = GIS.TrainModel(100, new OnePassRealValueDataIndexer(largeEventStream, 0), false); contexts = largeTest.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); values = RealValueFileEventStream.ParseContexts(contexts); var largeResults = largeModel.Eval(contexts, values); var largeResultString = smallModel.GetAllOutcomes(largeResults); Console.Out.WriteLine("largeResults: " + largeResultString); Assert.AreEqual(smallResults.Length, largeResults.Length); for (var i = 0; i < smallResults.Length; i++) { /* System.out.println(string.format( "classify with smallModel: %1$s = %2$f", smallModel.getOutcome(i), smallResults[i])); System.out.println(string.format( "classify with largeModel: %1$s = %2$f", largeModel.getOutcome(i), largeResults[i])); */ Assert.AreEqual(smallResults[i], largeResults[i], 0.01f); } }