예제 #1
0
        public static string Test()
        {
            var r = new MarkovChain <string>();

            r.setEndNodeName("END");
            r.setStartNodeName("START");
            r.AddTransaction("A", "B");
            r.AddTransaction("A", "B");
            r.AddTransaction("A", "B", "C");
            r.AddTransaction("A", "B", "C");
            r.AddTransaction("A", "B", "C", "D");
            r.AddTransaction("A", "B", "C", "E");
            r.AddTransaction("A", "C", "E");
            r.AddTransaction("A", "C", "E");
            r.AddTransaction("A", "B", "D");
            r.AddTransaction("A", "B", "D");
            r.AddTransaction("A", "B", "D", "E");
            r.AddTransaction("B", "C");
            r.AddTransaction("B", "C");
            r.AddTransaction("B", "C", "D");
            r.AddTransaction("B", "C", "E");
            r.AddTransaction("B", "D", "E");

            string res = "";

            foreach (var t in r.GetAllItems())
            {
                res += bulidTestResult(r, t) + "--------------- \r\n";
            }

            res += "\r\n\r\n" + (r.Probability("START", "C"));
            return(res);
        }
예제 #2
0
        static string bulidTestResult(MarkovChain <string> r, string v)
        {
            string s = v + "\r\n" + r.GetItem(v).Occurrence + "\r\n";

            foreach (var t in r.PredicteNext(v))
            {
                s += "[" + t.State + "] - " + t.Value + " - " + t.Occurrence + " - " + r.GetItem(v).ProbabilityOf(t) + "\r\n";
            }
            return(s + "\r\n");
        }
예제 #3
0
 private void bulidMarkov()
 {
     Print("_______________________");
     markover = new MarkovChain <string>();
     foreach (var e in extractedUsers)
     {
         foreach (var s in e.Sessions)
         {
             markover.AddTransaction(s.Requests.Select(x => x.RequstedPage).ToList());
         }
     }
     Print("Markov model has been build");
 }