public IFuzzySystem UniversalMethod(IFuzzySystem FSystem, ILearnAlgorithmConf conf) { init(FSystem, conf); for (int m = 0; m < max_Features; m++) { for (int i = 0; i < FSystem.CountFeatures; i++) { if (BestSolute[i] == true) { continue; } test.Add(BestSolute.Clone() as bool[]); test[test.Count - 1][i] = true; FSystem.AcceptedFeatures = test[test.Count - 1]; Errors.Add(FSystem.ErrorLearnSamples(FSystem.AbstractRulesBase()[0])); } int best = Errors.IndexOf(Errors.Min()); BestSolute = test[best].Clone() as bool[]; FSystem.AcceptedFeatures = BestSolute; Storage.Add(new FeatureSelectionModel(FSystem, BestSolute)); test.Clear(); Errors.Clear(); } Storage = FeatureSelectionModel.Distinct(Storage); FeatureSelectionModel.Sort(Storage, SortWay); return(FSystem); }
public void newclass() { for (int q = 0; q < MCount; q++) { if (test[q].Count(x => x == true) == 0) { test[q][rand.Next(BestSolute.Count())] = true; } ; theFuzzySystem.AcceptedFeatures = test[q]; Errors[q] = theFuzzySystem.ErrorLearnSamples(theFuzzySystem.AbstractRulesBase()[0]); if (Errors[q] < Ebest) { Ebest = Errors[q]; BestSolute = test[q].Clone() as bool[]; // Best_remebed = rules; Console.WriteLine("Найдена частица с ошибкой E=" + Errors[q]); Storage.Add(new FeatureSelectionModel(theFuzzySystem, BestSolute)); } int true_count = test[q].Count(x => x == true); if ((true_count <= open_Features) && (Errors[q] != Ebest) && (Errors[q] < Ebest1)) { GoodSolute = test[q].Clone() as bool[]; Storage.Add(new FeatureSelectionModel(theFuzzySystem, GoodSolute)); Console.WriteLine("Найдена дубль-частица с ошибкой E=" + Errors[q]); } Console.WriteLine(Errors[q]); } }
public IFuzzySystem UniversalMethod(IFuzzySystem FSystem, ILearnAlgorithmConf config) { init(FSystem, config); ////////////////////////////////////////////////////////////////////////////////////Первоначальная генерация for (int u = 0; u < MCount; u++) { ///Создаем частицу for (int i = 0; i < max_Features; i++) { if (rand.NextDouble() > 0.5) { Solute[i] = true; } else { Solute[i] = false; } } ///Проверяем, есть ли признаки. Если частица пуста, рандомный признак становится единицей if (Solute.Count(x => x == true) == 0) { BestSolute[rand.Next(BestSolute.Count())] = true; } ; //Заносим частицу в популяцию test.Add(Solute.Clone() as bool[]); //Заносим признаки в классификатор FSystem.AcceptedFeatures = test[test.Count - 1]; Errors.Add(FSystem.ErrorLearnSamples(FSystem.AbstractRulesBase()[0])); if (Errors[u] < Ebest) { Ebest = Errors[u]; BestSolute = test[u].Clone() as bool[]; Console.WriteLine("Найдена частица с ошибкой E=" + Errors[u]); Storage.Add(new FeatureSelectionModel(FSystem, BestSolute)); } Console.WriteLine(Errors[u]); } /////////////////////////////////////////// Сгенерировали первоначальные частицы, ура! algoritm(); Storage = FeatureSelectionModel.Distinct(Storage); FeatureSelectionModel.Sort(Storage, SortWay); FSystem.AcceptedFeatures = BestSolute; return(FSystem); }
public FeatureSelectionModel(IFuzzySystem Fsystem, bool[] FeaturesSource) { bool[] temp = Fsystem.AcceptedFeatures; Features = FeaturesSource; Fsystem.AcceptedFeatures = Features; Error = Fsystem.ErrorLearnSamples(Fsystem.AbstractRulesBase()[0]); ErrorTest = Fsystem.ErrorTestSamples(Fsystem.AbstractRulesBase()[0]); Fsystem.AcceptedFeatures = temp; if (Fsystem is PCFuzzySystem) { Accuracy = 100.0 - Error; AccuracyTest = 100.0 - ErrorTest; } else { Error = Fsystem.RMSEtoMSEforLearn(Error); ErrorTest = Fsystem.RMSEtoMSEforTest(ErrorTest); } Info = makeNameFeatures(Fsystem, Features); }