Ejemplo n.º 1
0
            public ProbabilityIndex(List <Email> emails, SmoothingStyle style)
            {
                Style          = style;
                SpamIndex      = new Dictionary <string, double>();
                HamIndex       = new Dictionary <string, double>();
                totalSpamWords = emails.Where(email => email.IsSpam).Sum(email => email.Words.Sum(word => word.Value));
                totalHamWords  = emails.Where(email => !email.IsSpam).Sum(email => email.Words.Sum(word => word.Value));

                BuildIndex(SpamIndex, emails.FindAll(doc => doc.IsSpam));
                BuildIndex(HamIndex, emails.FindAll(doc => !doc.IsSpam));
                SpamClass = CalcClassProbability(emails, true);
                HamClass  = CalcClassProbability(emails, false);
            }
Ejemplo n.º 2
0
 public SpamFilter(List <Email> trainingData, SmoothingStyle style)
 {
     index = new ProbabilityIndex(trainingData, style);
 }