Beispiel #1
0
 public virtual void UnlaidProtectionInMiddle(KnowlegeBaseRules current_database)
 {
     for (int i = 0; i < CountVars; i++)
     {
         if (AcceptedFeatures[i] == false)
         {
             continue;
         }
         List <Term> current_terms = current_database.TermsSet.FindAll(x => x.NumberOfInputVar == i);
         if (current_terms.Exists(x => x.TermFuncType == TypeTermFuncEnum.Гауссоида))
         {
             continue;
         }
         for (int j = 0; j < current_terms.Count - 1; j++)
         {
             if ((current_terms[j].Max < current_terms[j + 1].Min))
             {
                 double temp = current_terms[j].Max;
                 current_terms[j].Max     = current_terms[j + 1].Min;
                 current_terms[j + 1].Min = temp;
             }
             if (current_terms[j].Max == current_terms[j + 1].Min)
             {
                 current_terms[j].Max     += learnSamplesSet.InputAttributes[i].Scatter * 0.001;
                 current_terms[j + 1].Min -= learnSamplesSet.InputAttributes[i].Scatter * 0.001;
             }
         }
     }
 }
Beispiel #2
0
 public virtual void UnlaidProtectionFixMaxMinBorder(KnowlegeBaseRules Source)
 {
     for (int i = 0; i < CountVars; i++)
     {
         if (AcceptedFeatures[i] == false)
         {
             continue;
         }
         List <Term> all_terms_for_var =
             Source.TermsSet.FindAll(x => x.NumberOfInputVar == i);
         if (all_terms_for_var.Find(x => x.TermFuncType == TypeTermFuncEnum.Гауссоида) != null)
         {
             continue;
         }
         else
         {
             double min       = all_terms_for_var.Min(x => x.Min);
             int    min_index = all_terms_for_var.FindIndex(x => (x.Min == min));
             all_terms_for_var[min_index].Min =
                 learnSamplesSet.InputAttributes[i].Min - 0.001 * learnSamplesSet.InputAttributes[i].Scatter;
             //double max = double.NegativeInfinity;
             double max       = all_terms_for_var.Max(x => x.Max);
             int    max_index = all_terms_for_var.FindIndex(x => (x.Max == max));
             all_terms_for_var[max_index].Max = learnSamplesSet.InputAttributes[i].Max +
                                                0.001 * learnSamplesSet.InputAttributes[i].Scatter;
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// Часть метода геометрической коррекции базы правил, исправляет ситуацию когда существую на входных признаках области не принадлежащие ни одному из множеств.
        /// </summary>
        /// <param name="Source">База правил подлежащая исправлению методом геометрической проверки</param>
        protected virtual void UnlaidProtectionInMiddle(KnowlegeBaseRules Source)
        {
            Requires(Source != null);

            for (int i = 0; i < CountFeatures; i++)
            {
                if (AcceptedFeatures[i] == false)
                {
                    continue;
                }
                List <Term> TermsForVar = Source.TermsSet.FindAll(x => x.NumVar == i);
                if (TermsForVar.Exists(x => x.TermFuncType == TypeTermFuncEnum.Гауссоида))
                {
                    continue;
                }
                for (int j = 0; j < TermsForVar.Count - 1; j++)
                {
                    if ((TermsForVar[j].Max < TermsForVar[j + 1].Min))
                    {
                        double temp = TermsForVar[j].Max;
                        TermsForVar[j].Max     = TermsForVar[j + 1].Min;
                        TermsForVar[j + 1].Min = temp;
                    }
                    if (TermsForVar[j].Max == TermsForVar[j + 1].Min)
                    {
                        TermsForVar[j].Max     += LearnSamplesSet.InputAttributes[i].Scatter * 0.001;
                        TermsForVar[j + 1].Min -= LearnSamplesSet.InputAttributes[i].Scatter * 0.001;
                    }
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Часть метода геометрической коррекции базы правил, исправляет ситуацию когда для данных содержащих  минимальные или максимальные значения входящих признаков результат классификации или аппроксимации неопределен
        /// </summary>
        /// <param name="Source">База правил подлежащая исправлению методом геометрической проверки</param>
        protected virtual void UnlaidProtectionFixMaxMinBorder(KnowlegeBaseRules Source)
        {
            Requires(Source != null);

            for (int i = 0; i < CountFeatures; i++)
            {
                if (AcceptedFeatures[i] == false)
                {
                    continue;
                }
                List <Term> termsForVar =
                    Source.TermsSet.FindAll(x => x.NumVar == i);
                if (termsForVar.Find(x => x.TermFuncType == TypeTermFuncEnum.Гауссоида) != null)
                {
                    continue;
                }
                else
                {
                    double min       = termsForVar.Min(x => x.Min);
                    int    min_index = termsForVar.FindIndex(x => (x.Min == min));
                    termsForVar[min_index].Min =
                        LearnSamplesSet.InputAttributes[i].Min - 0.001 * LearnSamplesSet.InputAttributes[i].Scatter;
                    double max       = termsForVar.Max(x => x.Max);
                    int    max_index = termsForVar.FindIndex(x => (x.Max == max));
                    termsForVar[max_index].Max = LearnSamplesSet.InputAttributes[i].Max +
                                                 0.001 * LearnSamplesSet.InputAttributes[i].Scatter;
                }
            }
        }
Beispiel #5
0
 public virtual void UnlaidProtectionFix(KnowlegeBaseRules Source)
 {
     lock (Source)
     {
         UnlaidProtectionFixMaxMinBorder(Source);
         UnlaidProtectionInMiddle(Source);
         Source.TermsSet.Trim();
     }
 }
Beispiel #6
0
 /// <summary>
 /// Метод геометрической коррекции базы правил, гарантирует верное вычисление ошибки на обучающей и тестовой выборках за счёт разрешения ситуаций неопределенности (некоторые входные признаки неполностью покрыты функциями принадлежности)
 /// </summary>
 /// <param name="Source">База правил подлежащая исправлению методом геометрической проверки</param>
 public virtual void UnlaidProtectionFix(KnowlegeBaseRules Source)
 {
     Requires(Source != null);
     if (
         (double.IsInfinity(ErrorLearnSamples(Source))) ||
         (double.IsNaN(ErrorLearnSamples(Source))) ||
         (double.IsInfinity(ErrorTestSamples(Source))) ||
         (double.IsNaN(ErrorTestSamples(Source)))
         )
     {
         lock (Source)
         {
             UnlaidProtectionFixMaxMinBorder(Source);
             UnlaidProtectionInMiddle(Source);
             Source.TermsSet.Trim();
         }
     }
 }
Beispiel #7
0
 public abstract double ErrorLearnSamples(KnowlegeBaseRules Source);
Beispiel #8
0
        /// <summary>
        /// Функция получающая количество правил в заданной базе правил
        /// </summary>
        /// <param name="Source">База правил</param>
        /// <returns>Количество правил</returns>

        abstract public int ValueRuleCount(KnowlegeBaseRules Source);
Beispiel #9
0
 /// <summary>
 /// Функция получающая сложность заданной базы правил как суммы количества правил и термов
 /// </summary>
 /// <param name="Source">База правил</param>
 /// <returns>Сумма количества правил и термов</returns>
 abstract public int ValueComplexity(KnowlegeBaseRules Source);