示例#1
0
        public static ConfusionMatrix[] GetConfusionMatrixes(Model.Hierarchical.IHierarchicalClassifier classifier, Data.Dataset testset)
        {
            ConfusionMatrix[] list = new ConfusionMatrix[testset.Metadata.Target.Values.Length];


            foreach (Data.Example example in testset)
            {
                int[] predicted = classifier.Classify(example);
                int[] actual    = example.HierarchicalLabel;


                for (int classIndex = 0; classIndex < list.Length; classIndex++)
                {
                    if (predicted.Contains(classIndex))
                    {
                        if (actual.Contains(classIndex))
                        {
                            list[classIndex].TP++;
                        }
                        else
                        {
                            list[classIndex].FP++;
                        }
                    }
                    else
                    {
                        if (actual.Contains(classIndex))
                        {
                            list[classIndex].FN++;
                        }
                        else
                        {
                            list[classIndex].TN++;
                        }
                    }
                }
            }

            return(list);
        }
示例#2
0
 public double CalculateMeasure(DataMining.Model.IClassifier classifier, Data.Dataset dataset)
 {
     return(this.CalculateMeasure(ConfusionMatrix.ComputeConfusionMatrixes(classifier, dataset)));
 }