/// <summary>
        /// Calculate an error for a method that makes use of classification.
        /// </summary>
        /// <param name="method">The method to check.</param>
        /// <param name="data">The data to check.</param>
        /// <returns>The error.</returns>
        public static double CalculateClassificationError(IMLClassification method,
            IMLDataSet data)
        {
            int total = 0;
            int correct = 0;

            foreach (IMLDataPair pair in data)
            {
                var ideal = (int) pair.Ideal[0];
                int actual = method.Classify(pair.Input);
                if (actual == ideal)
                    correct++;
                total++;
            }
            return (total - correct)/(double) total;
        }
示例#2
0
        /// <summary>
        /// Calculate an error for a method that makes use of classification.
        /// </summary>
        /// <param name="method">The method to check.</param>
        /// <param name="data">The data to check.</param>
        /// <returns>The error.</returns>
        public static double CalculateClassificationError(IMLClassification method,
                                                          IMLDataSet data)
        {
            int total = 0;
            int correct = 0;

            foreach (IMLDataPair pair in data)
            {
                var ideal = (int)pair.Ideal[0];
                int actual = method.Classify(pair.Input);
                if (actual == ideal)
                    correct++;
                total++;
            }
            return (total - correct) / (double)total;
        }
示例#3
0
 public static double CalculateClassificationError(IMLClassification method, IMLDataSet data)
 {
     int num = 0;
     int num2 = 0;
     using (IEnumerator<IMLDataPair> enumerator = data.GetEnumerator())
     {
         int num3;
         int num4;
         goto Label_001B;
     Label_000E:
         if (num4 != num3)
         {
             goto Label_0017;
         }
     Label_0013:
         num2++;
     Label_0017:
         num++;
     Label_001B:
         if (!enumerator.MoveNext())
         {
             if (((uint) num2) > uint.MaxValue)
             {
                 goto Label_0013;
             }
         }
         else
         {
             IMLDataPair current = enumerator.Current;
             num3 = (int) current.Ideal[0];
             num4 = method.Classify(current.Input);
             goto Label_000E;
         }
     }
     return (((double) (num - num2)) / ((double) num));
 }