Example #1
0
        private string Predict(Congressman member)
        {
            var republicanProbability = this.GetProbability("republican", member);
            var democratProbability   = this.GetProbability("democrat", member);

            return(democratProbability > republicanProbability ? "democrat" : "republican");
        }
Example #2
0
        private double GetProbability(string party, Congressman member)
        {
            var probability = this.classNameProbabilities[party];

            this.attributesInfo.ToList().ForEach(a =>
            {
                probability *=
                    this.attributeProbabilities[party][a.Name][
                        (Vote)typeof(Congressman).GetProperty(a.Name).GetValue(member)];
            });

            return(probability);
        }