public void Work() { for (this._currentIteration = 0; this._currentIteration < this._maxIterations; this._currentIteration++) { this.CreateSolution(); this.PerformLocalSearch(); this.UpdateBestAnt(); if (this.IsConverged()) { break; } this.UpdatePheromoneLevels(); if (OnPostColonyIteration != null) { this.OnPostColonyIteration(this, null); } } this._mnClassifier = this.ConstructMulitNetClassifier(this._bestAnts); }
public override void Work() { this._mnClassifier = new BayesianMultinetClassifier(this._trainingSet.Metadata); DataMining.Data.Dataset[] datasets = this._trainingSet.Split(); for (int classIndex = 0; classIndex < this._trainingSet.Metadata.Target.Values.Length; classIndex++) { ((MICalculator)this._problem.HeuristicsCalculator).Dataset = datasets[classIndex]; this.Initialize(); ((likelihoodQualityEvaluator)this._problem.SolutionQualityEvaluator).QualityFactor = 0; ((likelihoodQualityEvaluator)this._problem.SolutionQualityEvaluator).TaregtClass = classIndex; ((likelihoodQualityEvaluator)this._problem.SolutionQualityEvaluator).TrainingSet = datasets[classIndex]; BayesianNetwork bayesianNetwork = this.LearnLocalBayesianNetwork(classIndex, datasets[classIndex]); this._mnClassifier.AddBayesianNetwork(classIndex, bayesianNetwork); } }
public static BayesianMultinetClassifier CreateGMNAntBayesianClassification(int seed, int iterations, int colonySize, int convergence, int dependencies, Dataset trainingSet, ISolutionQualityEvaluator <Edge> qualityEvaluator, IHeuristicValueCalculator <Edge> calculator, bool fireEvents) { DataMining.Utilities.RandomUtility.Initialize(seed); CyclicRelationInvalidator invalidator = new CyclicRelationInvalidator(); BackwardRemovalLocalSearch localSearch = new BackwardRemovalLocalSearch(qualityEvaluator); Problem <Edge> problem = new Problem <Edge>(invalidator, calculator, qualityEvaluator, localSearch); ABCMinerGMN mnabcminer = new ABCMinerGMN(iterations, colonySize, convergence, problem, dependencies, trainingSet); if (fireEvents) { mnabcminer.OnPostAntSolutionContruction += new EventHandler(abclassifier_OnPostAntSolutionContruction); mnabcminer.OnPostColonyIteration += new EventHandler(GMNabclassifier_OnPostColonyIteration); } mnabcminer.Work(); BayesianNetworks.Model.BayesianMultinetClassifier mnbclassifier = mnabcminer.MultinetBayesianClassifier; return(mnbclassifier); }