@Override public void Test() throws Exception { int bestId = this.GetBestTrainRun(); EvalResultSet bestResult = this.trainResultsMap.GetBestResult(); AbstractParameterDictionary bestParams = this.trainResultsMap.GetParams(bestId); String outputDirPath = this.inputParameters.GetStringValue("outputDir"); File wdFile = new File(outputDirPath, "test_fold_" + this.GetFoldId() + "winDiff.txt"); if (this.inputParameters.GetBooleanValue("useWDPerLevel") != null && this.inputParameters.GetBooleanValue("useWDPerLevel").booleanValue() == true) bestParams.SetValue("wdPerLevelPath", wdFile.getCanonicalPath()); HierarchicalAPSSimpleRun testHierRun = new HierarchicalAPSSimpleRun(); testHierRun.Init(bestParams); testHierRun.SetInputFiles(this.GetTestFiles()); testHierRun.ComputePreliminaryFrequencies(null); EvalResultSet curResult = testHierRun.Evaluate(bestParams); // EvalResultSet curResult = this.GenerateRandomValues(this.GetTestFiles()); this.testResultsMap.AddEntry(curResult, bestParams); }
@Override public void Train() throws Exception { ArrayList<Double> winRatios = this.inputParameters.GetNumericList("windowRatio"); ArrayList<Boolean> useSegmDfs = this.inputParameters.GetBooleanList("useSegmentDf"); ArrayList<Boolean> useWeightedTfs = this.inputParameters.GetBooleanList("useWeightedTf"); ArrayList<Double> numSegms = this.inputParameters.GetNumericList("numTFIDFsegments"); ArrayList<Boolean> smoothValues = this.inputParameters.GetBooleanList("smoothing"); ArrayList<Double> smoothingWindows = this.inputParameters.GetNumericList("smoothingWindow"); ArrayList<Double> smoothingAlphas = this.inputParameters.GetNumericList("smoothingAlpha"); ArrayList<Double> damps = this.inputParameters.GetNumericList("damping"); ArrayList<Double> prefs0 = this.inputParameters.GetNumericList("preference_level0"); ArrayList<Double> prefs1 = this.inputParameters.GetNumericList("preference_level1"); ArrayList<Double> prefs2 = this.inputParameters.GetNumericList("preference_level2"); Boolean useDf = new Boolean(false); HierarchicalAPSSimpleRun hierRun = new HierarchicalAPSSimpleRun(); hierRun.Init(inputParameters); hierRun.SetInputFiles(this.devFiles); hierRun.ComputePreliminaryFrequencies(null); for (Double windowRatio : winRatios) { Boolean unsmoothedRun = false; for (Boolean curSmooth : smoothValues) { for (Double curPref0 : prefs0) { for (Double curPref1 : prefs1) { for (Double curPref2 : prefs2) { for (Double curDamp : damps) { for (Double parzenAlpha : smoothingAlphas) { for (Double parzenWindow : smoothingWindows) { APSParameterDictionary curParams = (APSParameterDictionary) this.inputParameters.clone(); // alter parameters curParams.SetValue("isHier", new Boolean(true)); curParams.SetValue("smoothing", curSmooth); curParams.SetValue("smoothingAlpha", parzenAlpha); curParams.SetValue("smoothingWindow", parzenWindow); curParams.SetValue("useSegmentDf", useDf); curParams.SetValue("windowRatio", windowRatio); curParams.SetValue("preference_level0", curPref0); curParams.SetValue("preference_level1", curPref1); curParams.SetValue("preference_level2", curPref2); curParams.SetValue("damping", curDamp); System.out.println("***Parameters on this iteration:"); curParams.PrintParametersInUse(); EvalResultSet curResult = hierRun.Evaluate(curParams); // System.gc(); //free memory // EvalResultSet curResult = // this.GenerateRandomValues(this.GetDevFiles()); this.trainResultsMap.AddEntry(curResult, curParams); } // end parzenWindow } // end parzenAlpha } // end curDamp } } } } // pref0 } }