Example #1
0
 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);
 }
Example #2
0
        public override string ToString(bool with_param = false)
        {
            if (with_param)
            {
                string result = "Жадный алгоритм +";
                result += " ; " + Environment.NewLine;
                result += FeatureSelectionModel.getFullInfo(Storage, isClass);

                result += "}";
                return(result);
            }
            return("Жадный алгоритм +");
        }
Example #3
0
        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);
        }
Example #4
0
        public override string ToString(bool with_param = false)
        {
            if (with_param)
            {
                string result = "Дискретная гравитация +";
                result += " ; " + Environment.NewLine;
                if (Storage != null)
                {
                    result += FeatureSelectionModel.getFullInfo(Storage, isClass);
                }

                result += "}";
                return(result);
            }
            return("Дискретная гравитация");
        }