public EvaluationResult <OutputType> Evaluate(ExampleSelection exampleSelection, EvaluationResult <OutputType> result) { if (exampleSelection is RandomSelection) { // randomize list of examples LearningData.Examples.Shuffle(); } else if (exampleSelection is ChronologicalSelection) { // input path of example cut off after last slash and remove .log then sort by that. LearningData.Examples.Sort((ex1, ex2) => GetBuildIdFromPath(ex1.InputPath).CompareTo(GetBuildIdFromPath(ex2.InputPath))); } else if (exampleSelection is ManualSelection) { // take examples in list they are defined in file (so sequence they have in the LearningData already) } for (int exampleCount = 1; exampleCount <= exampleSelection.LearningStepCount; exampleCount++) { SessionData <ExampleData <OutputType> > currentLearningData = new SessionData <ExampleData <OutputType> >(); currentLearningData.Examples = LearningData.Examples.GetRange(0, Math.Min(exampleCount, LearningData.Examples.Count)); if (exampleSelection.IncludeAllInputs) { currentLearningData.InputPaths = LearningData.InputPaths; } List <ExampleData <OutputType> > testSamples = LearningData.Examples.GetRange(exampleCount, Math.Min(exampleSelection.TestCount, LearningData.Examples.Count - exampleCount)); List <AnalysisResult <OutputType> > testResults = new List <AnalysisResult <OutputType> >(); foreach (ExampleData <OutputType> testSample in testSamples) { var analysisResult = ApplyToFileWithLearningData(Config.SAMPLE_DIRECTORY + testSample.InputPath, currentLearningData, new AnalysisResult <OutputType>(), false); analysisResult.DesiredOutput = testSample.Output; analysisResult.TestCategory = testSample.Category; // Console.WriteLine(ConsoleOutput.PrintAnalysisResult(analysisResult, 0, true)); testResults.Add(analysisResult); } result.Results.Add(currentLearningData, testResults); } return(result); }
public static EvaluationResult <OutputType> Evaluate <OutputType>(string programName, ExampleSelection exampleSelection) { var result = new EvaluationResult <OutputType>(); result.ExampleSelection = exampleSelection; result.ProgramName = programName; if (typeof(OutputType) == typeof(string)) { var program = AnalysisProgram <RegionAnalysisSession, string> .LoadAnalysisProgram(programName); return((EvaluationResult <OutputType>)(object) program.Evaluate(exampleSelection, (EvaluationResult <string>)(object) result)); } if (typeof(OutputType) == typeof(string[])) { var program = AnalysisProgram <SequenceAnalysisSession, string[]> .LoadAnalysisProgram(programName); return((EvaluationResult <OutputType>)(object) program.Evaluate(exampleSelection, (EvaluationResult <string[]>)(object) result)); } return(result); }