コード例 #1
0
ファイル: TestFogbugz.cs プロジェクト: Gabo1988/Playground
        public void TestUsers()
        {
            var userParser = new Parser();

            userParser.BuildUsers(UsersXml);

            Assert.That(userParser.Users[12], Is.EqualTo("Sam Neff"));
        }
コード例 #2
0
ファイル: TestFogbugz.cs プロジェクト: Gabo1988/Playground
        public void TestCaseText()
        {
            var samCases = @"../../../Assets/Fogbugz/sam.xml";

            var userParser = new Parser();

            var cases = userParser.GetCases(UsersXml, samCases);
        }
コード例 #3
0
ファイル: TestFogbugz.cs プロジェクト: Gabo1988/Playground
        public void TestParser(string path)
        {                      
            var parser = new Parser();

            var cases = parser.GetCases(UsersXml, path);

            Func<Case, Document> caseTransform =
                i =>
                i.ToDoc(@case => @case.Area,
                        @case => @case.Title);

            #region Event Text comment 
            //@case.Events.Aggregate("", (acc, bug) => acc + " " + Regex.Replace(bug.Text, Regex.Escape("[") + "code" + Regex.Escape("]") + ".*" + Regex.Escape("[") + "/code" + Regex.Escape("]"), "")));
            #endregion

            var total = cases.Count();

            var trainingSet = cases.Take((int)(total * (3.0 / 4))).Select(caseTransform).ToList();

            var validationSet = cases.Skip((int)(total * (3.0 / 4))).Select(caseTransform).ToList();

            var trainedData = NaiveBayes.TrainBayes(trainingSet);

            var successRate = 0.0;

            foreach (var @case in validationSet)
            {
                if (NaiveBayes.Classify(@case, trainedData).Name == @case.Class.Name)
                {
                    successRate++;
                }
            }

            successRate = successRate/validationSet.Count();

            foreach (var type in trainedData.Probabilities)
            {
                Console.WriteLine(type.Class.Name);
                Console.WriteLine("--------------------");

                type.Top(10).ForEach(i => Console.WriteLine("[{1:0.00}] {0}", i.Word, i.Probability));

                Console.WriteLine();
                Console.WriteLine();
            }

            Console.WriteLine("Prediction success rate is {0:0.00}%", successRate * 100);
        }