/// <summary> /// Continues learning with recovered learning data. /// </summary> /// <param name="recoveredLr">Learning rounds that were already performed.</param> public void continueLearning(List <LearningRound> recoveredLr) { if (!hasNecessaryData()) { return; } if (this.mlSettings.bagging) { throw new NotImplementedException("Recovering with bagging currently dosent work"); } else { ObservableCollection <LearningRound> learningRounds = new ObservableCollection <LearningRound>(); GlobalState.logInfo.logLine("Learning progress:"); foreach (LearningRound lr in recoveredLr) { GlobalState.logInfo.logLine(lr.ToString()); learningRounds.Add(lr); } InfluenceModel infMod = new InfluenceModel(GlobalState.varModel, GlobalState.currentNFP); FeatureSubsetSelection sel = new FeatureSubsetSelection(infMod, this.mlSettings); this.models.Add(sel); sel.setLearningSet(testSet); sel.setValidationSet(this.validationSet); Stopwatch sw = new Stopwatch(); sw.Start(); sel.continueLearn(learningRounds); sw.Stop(); Console.WriteLine("Elapsed={0}", sw.Elapsed); } }
public void learn() { if (!hasNecessaryData()) { return; } if (this.mlSettings.bagging) { //Get number of cores int coreCount = System.Environment.ProcessorCount; createThreadPool(coreCount); this.nbBaggings = this.mlSettings.baggingNumbers; iCount = this.nbBaggings; Random rand = new Random(0); int nbOfConfigs = (testSet.Count * this.mlSettings.baggingTestDataFraction) / 100; for (int i = 0; i < nbBaggings; i++) { InfluenceModel infMod = new InfluenceModel(GlobalState.varModel, GlobalState.currentNFP); FeatureSubsetSelection sel = new FeatureSubsetSelection(infMod, this.mlSettings); this.models.Add(sel); List <int> selection = new List <int>(); for (int r = 0; r <= nbOfConfigs; r++) { selection.Add(rand.Next(nbOfConfigs)); } List <Configuration> newTestSet = new List <Configuration>(); List <Configuration> newValidationSet = new List <Configuration>(); for (int r = 0; r <= selection.Count; r++) { if (selection.Contains(r)) { newTestSet.Add(testSet[r]); } else { newValidationSet.Add(testSet[r]); } } sel.setLearningSet(newTestSet); sel.setValidationSet(newValidationSet); Task task = EnqueueTask(() => sel.learn()); } eventX.WaitOne(Timeout.Infinite, true); averageModels(); } else { GlobalState.logInfo.logLine("Learning progress:"); InfluenceModel infMod = new InfluenceModel(GlobalState.varModel, GlobalState.currentNFP); FeatureSubsetSelection sel = new FeatureSubsetSelection(infMod, this.mlSettings); this.models.Add(sel); sel.setLearningSet(testSet); sel.setValidationSet(this.validationSet); Stopwatch sw = new Stopwatch(); sw.Start(); sel.learn(); sw.Stop(); Console.WriteLine("Elapsed={0}", sw.Elapsed); } }