Esempio n. 1
0
        /// <summary>
        /// 计算峰值
        /// </summary>
        /// <param name="N">回览次数</param>
        /// <param name="K">成功次数</param>
        /// <param name="p">正常概率</param>



        public override List <ChanceClass> getChances(BaseCollection sc, ExpectData ed)
        {
            List <ChanceClass> ret   = new List <ChanceClass>();
            MLDataFactory      pkdls = new MLDataFactory();// this.LastUseData());
            //Dictionary<int, Dictionary<int, int>> res = pkdls.getAllShiftAndColMaxProbList(this.ReviewExpectCnt- this.InputMinTimes-1, this.InputMinTimes,true);
            List <MLFeature <int> >  features = pkdls.getAllSpecRowRoundFeatures(this.LastUseData().Count - 1, this.InputMinTimes, 0);
            Dictionary <string, int> AllCodes = new Dictionary <string, int>();

            for (int i = 0; i < features.Count; i++)
            {
                MLFeature <int> feature = features[i];
                MaxEnt          me      = new MaxEnt();
                if (MaxEnt.FeatureSummary == null)
                {
                    me.OnLoadLocalFile = LoadLocalTrainData;
                    me.LoadSummary();
                }
                me.FillStructBySummary(i);
                MLInstance <int, int> instance = new MLInstance <int, int>(feature);
                int label = me.Classify(instance);
                if (label < 0)
                {
                    continue;
                }
                string strAllCode = string.Format("{0}/{1}", (i + 1) % 10, label);
                AllCodes.Add(strAllCode, 1);
            }

            ////foreach (int key in res.Keys)
            ////    AllCodes.Add(string.Format("{0}/{1}",key,string.Join("",res[key].Keys.ToArray())),1);


            if (true)
            {
                ChanceClass cc = new ChanceClass();
                cc.SignExpectNo  = ed.Expect;
                cc.ChanceType    = 2;
                cc.InputTimes    = 1;
                cc.strInputTimes = string.Join("_", new string[2] {
                    "1", "1"
                });
                //cc.AllowMaxHoldTimeCnt = this.AllowMaxHoldTimeCnt;
                cc.InputExpect = ed;
                cc.StragId     = this.GUID;
                //cc.MinWinRate = this.CommSetting.GetGlobalSetting().DefaultHoldAmtSerials.MaxRates[cc.ChipCount - 1];
                cc.IsTracer            = 0;
                cc.HoldTimeCnt         = 1;
                cc.Odds                = this.CommSetting.GetGlobalSetting().Odds;
                cc.ExpectCode          = ed.Expect;
                cc.ChanceCode          = string.Join("+", AllCodes.Keys.ToArray());
                cc.ChipCount           = ChanceClass.getChipsByCode(cc.ChanceCode);
                cc.CreateTime          = DateTime.Now;
                cc.UpdateTime          = DateTime.Now;
                cc.AllowMaxHoldTimeCnt = 1;
                cc.Closed              = false;
                ret.Add(cc);
            }

            return(ret);
        }
Esempio n. 2
0
        public Dictionary <int, double> getMaxProb(int col, int shiftCol, int TestLength, int LastTimes, bool LastisSerial)
        {
            Dictionary <int, double> ret      = new Dictionary <int, double>();
            List <Instance>          TrainSet = OccurrTestInstances(col, shiftCol, TestLength, LastTimes, LastisSerial);
            List <Instance>          TestSet  = getLastFeatures(col, shiftCol, Data.Count - 1, LastTimes, LastisSerial);

            ret = MaxEnt.getLabels(TrainSet, TestSet);


            return(ret);
        }