示例#1
0
 public void TestCountTruePositives()
 {
     Assert.AreEqual(0, FMeasure <object> .CountTruePositives(new object[] {}, new object[] {}));
     Assert.AreEqual(gold.Length, FMeasure <object> .CountTruePositives(gold, gold));
     Assert.AreEqual(0, FMeasure <object> .CountTruePositives(gold, predictedCompletelyDistinct));
     Assert.AreEqual(2, FMeasure <object> .CountTruePositives(gold, predicted));
 }
示例#2
0
        public void TestMerge()
        {
            var fm = new FMeasure <object>();

            fm.UpdateScores(gold, predicted);
            fm.UpdateScores(goldToMerge, predictedToMerge);

            var fmMerge = new FMeasure <object>();

            fmMerge.UpdateScores(gold, predicted);
            var toMerge = new FMeasure <object>();

            toMerge.UpdateScores(goldToMerge, predictedToMerge);
            fmMerge.MergeInto(toMerge);

            double selected1 = predicted.Length;
            double target1   = gold.Length;
            double tp1       = FMeasure <object> .CountTruePositives(gold, predicted);

            double selected2 = predictedToMerge.Length;
            double target2   = goldToMerge.Length;
            double tp2       = FMeasure <object> .CountTruePositives(goldToMerge, predictedToMerge);


            Assert.AreEqual((tp1 + tp2) / (target1 + target2), fm.RecallScore, Delta);
            Assert.AreEqual((tp1 + tp2) / (selected1 + selected2), fm.PrecisionScore, Delta);

            Assert.AreEqual(fm.RecallScore, fmMerge.RecallScore, Delta);
            Assert.AreEqual(fm.PrecisionScore, fmMerge.PrecisionScore, Delta);
        }