/// <summary> /// 产生环绕Label的实例,深度为0是下一,基本配置,深度为1则是左1,下一,下二,右一,以此类推 /// </summary> /// <returns></returns> public MLFeature <int> getSpecRowRoundFeatures(long rowid, int col, int Deep, int AllowLRShift) { MLFeature <int> feature = new MLFeature <int>(); if ((rowid) - Deep < 0)//rowid 至少要大于等于Deep; { return(feature); } long baseIndex = rowid; for (int i = -1 * Deep * AllowLRShift; i <= 1 * Deep * AllowLRShift; i++) //偏移 { int BColIndex = (col + i) % 10; //对于大于10的取模 if (BColIndex < 0) //对于小于0的,+10 如:0 + (-1) = 9 { BColIndex = BColIndex + 10; } for (int j = 0; j <= Deep; j++) { if ((i * i + j * j) <= Deep * Deep)//深度内 { int Fval = int.Parse(Data[(int)baseIndex - j].ValueList[BColIndex]); feature.Add(Fval); } } } return(feature); }
/// <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); }