Пример #1
0
        /// <summary>
        /// Determine the mode, this is the class item that has the most instances.
        /// </summary>
        /// <param name="analyst">The analyst to use.</param>
        /// <returns>The mode.</returns>
        public int DetermineMode(EncogAnalyst analyst)
        {
            if (!Classify)
            {
                throw new AnalystError("Can only calculate the mode for a class.");
            }

            DataField        df = analyst.Script.FindDataField(Name);
            AnalystClassItem m  = null;
            int result          = 0;
            int idx             = 0;

            foreach (AnalystClassItem item in df.ClassMembers)
            {
                if (m == null || m.Count < item.Count)
                {
                    m      = item;
                    result = idx;
                }
                idx++;
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        ///     Perform a pass one analysis of this field.
        /// </summary>
        /// <param name="str">The current value.</param>
        public void Analyze1(String v)
        {
            bool   accountedFor = false;
            string str          = v.Trim();

            if (str.Trim().Length == 0 || str.Equals("?"))
            {
                Complete = false;
                return;
            }

            _instances++;

            if (Real)
            {
                try
                {
                    double d = _fmt.Parse(str);
                    Max          = Math.Max(d, Max);
                    Min          = Math.Min(d, Min);
                    _total      += d;
                    accountedFor = true;
                }
                catch (FormatException)
                {
                    Real = false;
                    if (!Integer)
                    {
                        Max = 0;
                        Min = 0;
                        StandardDeviation = 0;
                    }
                }
            }

            if (Integer)
            {
                try
                {
                    int i = Int32.Parse(str);
                    Max = Math.Max(i, Max);
                    Min = Math.Min(i, Min);
                    if (!accountedFor)
                    {
                        _total += i;
                    }
                }
                catch (FormatException)
                {
                    Integer = false;
                    if (!Real)
                    {
                        Max = 0;
                        Min = 0;
                        StandardDeviation = 0;
                    }
                }
            }

            if (Class)
            {
                AnalystClassItem item;

                // is this a new class?
                if (!_classMap.ContainsKey(str))
                {
                    item           = new AnalystClassItem(str, str, 1);
                    _classMap[str] = item;

                    // do we have too many different classes?
                    int max = _script.Properties.GetPropertyInt(
                        ScriptProperties.SetupConfigMaxClassCount);
                    if (_classMap.Count > max)
                    {
                        Class = false;
                    }
                }
                else
                {
                    item = _classMap[str];
                    item.IncreaseCount();
                }
            }
        }
        /// <summary>
        ///     Perform a pass one analysis of this field.
        /// </summary>
        /// <param name="str">The current value.</param>
        public void Analyze1(String v)
        {
            bool accountedFor = false;
            string str = v.Trim();

            if (str.Trim().Length == 0 || str.Equals("?"))
            {
                Complete = false;
                return;
            }

            _instances++;

            if (Real)
            {
                try
                {
                    double d = _script.DetermineFormat().Parse(str);
                    Max = Math.Max(d, Max);
                    Min = Math.Min(d, Min);
                    _total += d;
                    accountedFor = true;
                }
                catch (FormatException)
                {
                    Real = false;
                    if (!Integer)
                    {
                        Max = 0;
                        Min = 0;
                        StandardDeviation = 0;
                    }
                }
            }

            if (Integer)
            {
                try
                {
                    int i = Int32.Parse(str);
                    Max = Math.Max(i, Max);
                    Min = Math.Min(i, Min);
                    if (!accountedFor)
                    {
                        _total += i;
                    }
                }
                catch (FormatException)
                {
                    Integer = false;
                    if (!Real)
                    {
                        Max = 0;
                        Min = 0;
                        StandardDeviation = 0;
                    }
                }
            }

            if (Class)
            {
                AnalystClassItem item;

                // is this a new class?
                if (!_classMap.ContainsKey(str))
                {
                    item = new AnalystClassItem(str, str, 1);
                    _classMap[str] = item;

                    // do we have too many different classes?
                    int max = _script.Properties.GetPropertyInt(
                        ScriptProperties.SetupConfigMaxClassCount);
                    if (_classMap.Count > max)
                    {
                        Class = false;
                    }
                }
                else
                {
                    item = _classMap[str];
                    item.IncreaseCount();
                }
            }
        }
Пример #4
0
 private static int x423166c51d1af5d1(int x3bd62873fafa6252, AnalystClassItem xc42b25352a9f8ae1)
 {
     return Math.Min(x3bd62873fafa6252, xc42b25352a9f8ae1.Count);
 }
Пример #5
0
 public void Analyze1(string v)
 {
     string str;
     double num;
     int num2;
     int propertyInt;
     bool flag = false;
     goto Label_033F;
     Label_0007:
     if (base.Class)
     {
         if (!this._x785cd8b1f9494d74.ContainsKey(str))
         {
             AnalystClassItem item = new AnalystClassItem(str, str, 1);
             this._x785cd8b1f9494d74[str] = item;
             propertyInt = this._x594135906c55045c.Properties.GetPropertyInt("SETUP:CONFIG_maxClassCount");
             if (this._x785cd8b1f9494d74.Count > propertyInt)
             {
                 base.Class = false;
                 return;
             }
             if ((((uint) num2) + ((uint) propertyInt)) <= uint.MaxValue)
             {
                 return;
             }
             goto Label_033F;
         }
     }
     else
     {
         return;
     }
     this._x785cd8b1f9494d74[str].IncreaseCount();
     return;
     Label_00BD:
     if (base.Integer)
     {
         goto Label_00CF;
     }
     goto Label_0007;
     Label_00CC:
     if (0 == 0)
     {
         goto Label_00BD;
     }
     Label_00CF:
     try
     {
         num2 = int.Parse(str);
         goto Label_00F0;
     Label_00DA:
         this._xb1c30745a1525188 += num2;
         goto Label_0007;
     Label_00EB:
         if (!flag)
         {
             goto Label_00DA;
         }
         goto Label_0007;
     Label_00F0:
         base.Max = Math.Max((double) num2, base.Max);
         base.Min = Math.Min((double) num2, base.Min);
         goto Label_00EB;
     }
     catch (FormatException)
     {
         goto Label_014F;
     Label_0120:
         base.Min = 0.0;
         base.StandardDeviation = 0.0;
         goto Label_0007;
     Label_0140:
         if (!base.Real)
         {
             goto Label_015C;
         }
         if (2 != 0)
         {
             goto Label_0007;
         }
     Label_014F:
         base.Integer = false;
         if (0 == 0)
         {
             goto Label_0140;
         }
         if (0 != 0)
         {
             goto Label_0007;
         }
     Label_015C:
         base.Max = 0.0;
         if (((uint) flag) <= uint.MaxValue)
         {
             goto Label_0120;
         }
     }
     goto Label_0007;
     if ((((uint) num) - ((uint) propertyInt)) >= 0)
     {
         goto Label_00CC;
     }
     if (0 == 0)
     {
         goto Label_01CB;
     }
     if (((uint) num2) <= uint.MaxValue)
     {
         if (((uint) flag) > uint.MaxValue)
         {
             goto Label_00BD;
         }
         goto Label_031B;
     }
     Label_01B8:
     if (base.Real)
     {
         goto Label_021C;
     }
     goto Label_00CC;
     Label_01CB:
     if (str.Equals("?"))
     {
         goto Label_031B;
     }
     if ((((uint) num2) - ((uint) num2)) < 0)
     {
         goto Label_0346;
     }
     this._x0eba5dc834af0bac++;
     if ((((uint) flag) | uint.MaxValue) != 0)
     {
         goto Label_01B8;
     }
     Label_021C:
     try
     {
         num = CSVFormat.EgFormat.Parse(str);
         base.Max = Math.Max(num, base.Max);
         base.Min = Math.Min(num, base.Min);
         this._xb1c30745a1525188 += num;
         flag = true;
     }
     catch (FormatException)
     {
         if ((((uint) flag) | 2) != 0)
         {
             goto Label_02AB;
         }
     Label_027A:
         base.StandardDeviation = 0.0;
     Label_0289:
         if ((((uint) num2) | 2) != 0)
         {
             goto Label_00BD;
         }
     Label_02A1:
         if (!base.Integer)
         {
             goto Label_02B4;
         }
         goto Label_00BD;
     Label_02AB:
         base.Real = false;
         goto Label_02A1;
     Label_02B4:
         base.Max = 0.0;
         base.Min = 0.0;
         if (((uint) num) > uint.MaxValue)
         {
             goto Label_0289;
         }
         if ((((uint) flag) - ((uint) propertyInt)) >= 0)
         {
             goto Label_027A;
         }
     }
     goto Label_00BD;
     Label_031B:
     base.Complete = false;
     return;
     Label_033F:
     str = v.Trim();
     Label_0346:
     if (str.Trim().Length == 0)
     {
         goto Label_031B;
     }
     goto Label_01CB;
 }