Exemple #1
0
        BayesDicClass OccurrDir(int col, int TestLength, int LastTimes)//add by zhouys 2019/1/15
        {
            BayesDicClass ret    = new BayesDicClass();
            int           iShift = Data.Count - TestLength;

            if (iShift <= LastTimes) //Data length must more than TestLength+LastTimes+1
            {
                return(ret);
            }
            Dictionary <string, int> defaultDic = getDefaultCombDic();
            Dictionary <int, int>    PreA       = InitPriorProbabilityDic();
            Dictionary <int, int>    PreB       = InitPriorProbabilityDic();
            //for (int col=0;col<10;col++)
            //{
            Dictionary <string, int> combDic = defaultDic;

            for (int i = iShift - 1; i < Data.Count; i++)
            {
                int    CurrA = getIntValue(Data[i].ValueList[col]);
                int    CurrB = getIntValue(Data[i - LastTimes].ValueList[col]);
                string key   = string.Format("{0}_{1}", CurrA, CurrB);
                int    cnt   = combDic[key];
                combDic[key] = cnt + 1;
                PreA[CurrA]  = PreA[CurrA] + 1;
                PreB[CurrB]  = PreB[CurrB] + 1;
            }
            ret.PosteriorProbDic = combDic;
            ret.PriorProbDicA    = PreA;
            ret.PriorProbDicB    = PreB;
            ret.TestLength       = TestLength;
            //}
            return(ret);
        }
Exemple #2
0
        public Dictionary <string, double> OccurColumnProb(int col, int TestLength, int LastTimes)
        {
            Dictionary <string, double> ret = new Dictionary <string, double>();
            BayesDicClass bdic = OccurrDir(col, TestLength, LastTimes);

            ret = bdic.getBA();
            return(ret);
        }
Exemple #3
0
        public Dictionary <int, List <int> > OccurProbList(int TestLength, int LastTimes, int SelectListCnt)
        {
            Dictionary <int, List <int> > ret = new Dictionary <int, List <int> >();

            for (int i = 0; i < 10; i++)
            {
                Dictionary <string, double> res = OccurColumnProb(i, TestLength, LastTimes);
                string str = Data.LastData.ValueList[i];
                //str = str == "0" ? "10" : str;
                int        col     = (i + 1) % 10;
                List <int> colList = BayesDicClass.getBAMaxNValue(res, int.Parse(str), SelectListCnt);
                ret.Add(col, colList);
            }
            return(ret);
        }