예제 #1
0
        public static double FMeasure(Item[] instances, DecisionForest forest, AttributeVariable target_attribute, double B = 1)
        {
            double precision = Precision(instances, forest, target_attribute);
            double recall    = Recall(instances, forest, target_attribute);

            return((B * B + 1) * precision * recall / (B * B * precision + recall));
        }
예제 #2
0
        public static double Recall(Item[] instances, DecisionForest forest, AttributeVariable target_attribute)
        {
            int tp = 0, fn = 0;

            foreach (var item in instances)
            {
                int true_value    = (int)item.FindAttributeValue(target_attribute);
                int predict_value = (int)Math.Round(forest.Decide(item));

                if (true_value == 1)
                {
                    if (predict_value == 1)
                    {
                        ++tp;
                    }
                    else
                    {
                        ++fn;
                    }
                }
            }

            return((double)tp / (double)(tp + fn));
        }