Ejemplo n.º 1
0
        public static double ComputeROCAUCTrapeziod <RealType>(IList <bool> labels, IList <RealType> sample)
            where RealType : IComparable <RealType>
        {
            int    postive_count            = ToolsCollection.CountOccurance(labels, true);
            double true_positive_increment  = 1.0 / postive_count;
            double false_positive_increment = 1.0 / (labels.Count - postive_count);

            double[]   true_positive_rates  = new double[labels.Count + 1];
            double[]   false_positive_rates = new double[labels.Count + 1];
            List <int> ordering             = ToolsMathCollection.Ordering(sample);


            for (int index = 1; index < labels.Count + 1; index++)
            {
                if (labels[ordering[index - 1]])
                {
                    true_positive_rates[index]  = true_positive_rates[index - 1] + true_positive_increment;
                    false_positive_rates[index] = false_positive_rates[index - 1];
                }
                else
                {
                    true_positive_rates[index]  = true_positive_rates[index - 1];
                    false_positive_rates[index] = false_positive_rates[index - 1] + false_positive_increment;
                }
            }
            return(IntegralEvaluatorTrapezoid.EvaluateStaticValue(false_positive_rates, true_positive_rates));
        }
Ejemplo n.º 2
0
        public static RealType MeanAll <RealType>(IAlgebraReal <RealType> algebra, IList <IList <RealType> > samples)
        {
            RealType total_count = algebra.AddIdentity;
            RealType total_sum   = algebra.AddIdentity;

            foreach (IList <RealType> sample in samples)
            {
                total_count = algebra.Add(total_count, algebra.ToDomain((float)sample.Count));
                total_sum   = algebra.Add(total_sum, ToolsMathCollection.Sum(algebra, sample));
            }
            return(algebra.Divide(total_sum, total_count));
        }
 public static double[] Shift(double[] domain, double[] range, double shift)
 {
     return(Resample(domain, range, ToolsMathCollection.Add(domain, shift)));
 }
Ejemplo n.º 4
0
 public static RealType Mean <RealType>(
     IAlgebraReal <RealType> algebra,
     IList <RealType> sample_0)
 {
     return(algebra.Divide(ToolsMathCollection.Sum(algebra, sample_0), algebra.ToDomain((float)sample_0.Count)));
 }