Ejemplo n.º 1
0
        private String  PartialCreditIdxToStr(PartialCreditIdx idx)
        {
            String s = "None";

            switch (idx)
            {
            case  PartialCreditIdx.None:        s = "None";        break;

            case  PartialCreditIdx.Whole:       s = "Whole";       break;

            case  PartialCreditIdx.OneHalf:     s = "OneHalf";     break;

            case  PartialCreditIdx.OneThird:    s = "OneThird";    break;

            case  PartialCreditIdx.TwoThirds:   s = "TwoThirds";   break;

            case  PartialCreditIdx.OneForth:    s = "OneForth";    break;

            case  PartialCreditIdx.TwoForths:   s = "TwoForths";   break;

            case  PartialCreditIdx.ThreeForths: s = "ThreeForths"; break;
            }

            return(s);
        }
Ejemplo n.º 2
0
        private void  MakePrediction(Prediction p)
        {
            String rootName = OSservices.GetRootName(p.FileName);

            PicesClass knownClassPredLevel = p.knowClass.MLClassForGivenHierarchialLevel(predLevel);
            PicesClass predClassPredLevel  = p.predClass.MLClassForGivenHierarchialLevel(predLevel);

            int knowClassIdx = classesPredLevel.LookUpIndex(knownClassPredLevel);
            int predClassIdx = classesPredLevel.LookUpIndex(predClassPredLevel);

            int   exactMatch    = 0;
            float partialCredit = 0.0f;

            if (knowClassIdx == predClassIdx)
            {
                partialCredit = 1.0f;
                exactMatch    = 1;
            }
            else
            {
                partialCredit = FractionThatIsAMatch2(knownClassPredLevel, predClassPredLevel);
            }

            PartialCreditIdx pcIdx = DerivePartialCreditIdx(partialCredit);

            totalByCorectLevel[(int)pcIdx]++;
            totalCount++;
            totalCorrect    += partialCredit;
            totalCorrectNPC += exactMatch;

            if (!p.partOfClassifier)
            {
                totalNotPartOfClassifier++;
            }
            else
            {
                totalPartOfClassifier++;
                totalPartOfClassifierByCorectLevel[(int)pcIdx]++;
                totalPartOfClassifierCorrect    += partialCredit;
                totalPartOfClassifierCorrectNPC += exactMatch;

                if (p.knowClass.UnDefined)
                {
                    totalNoise++;
                    totalNoiseCorrect    += partialCredit;
                    totalNoiseCorrectNPC += exactMatch;
                }
                else
                {
                    totalNonNoise++;
                    totalNonNoiseCorrect    += partialCredit;
                    totalNonNoiseCorrectNPC += exactMatch;
                }
            }

            if (knowClassIdx < 0)
            {
                MessageBox.Show("Invalid Class Specified[" + p.knowClass.Name + "]");
                return;
            }

            if (predClassIdx < 0)
            {
                MessageBox.Show("Invalid Class Specified[" + p.predClass.Name + "]");
                return;
            }

            knownClassCounts[knowClassIdx]++;
            predClassCounts [predClassIdx]++;
            predictionCounts[knowClassIdx][predClassIdx]++;

            try { imagesByPred[knowClassIdx][predClassIdx].Add(rootName, p); }
            catch (Exception e)
            {
                MessageBox.Show(this, "Exception occurred adding example[" + rootName + "]" + "\n" +
                                "Known Class[" + p.knowClass.Name + "] Pred Class[" + p.predClass.Name + "]" + "\n" +
                                "Exception [" + e.ToString() + "]" + "\n" +
                                e.StackTrace,
                                "Confusion Matrix",
                                MessageBoxButtons.OK
                                );
            }
        } /* MakePrediction */