public static void toolStripValidateOneRule(object sender, EventArgs e) { var t = Task.Factory.StartNew(() => { TwoColorBall twoColorBall = new TwoColorBall(Config.GetConfig<int>("CalculateRows")); bool[] res = twoColorBall.ValidateRuleList(new RuleInfo[] { GetCurrentRule() })[0]; double rate = ((double )res.Where(n => n).Count()) /(double )res.Length; MainForm.FilterDM.dgv.CurrentRow.Cells[6].Value = rate.ToString("F4"); }); }
/// <summary> /// 交叉验证功能:几个规则同时进行验证,准确率在下方状态显示,也包括了单独的验证 /// </summary> public static void toolStripCrossValidate_Click(object sender, EventArgs e) { TwoColorBall twoColorBall = new TwoColorBall(Config.GetConfig<int>("CalculateRows")); var t = Task.Factory.StartNew(() => { bool[][] result = twoColorBall.ValidateRuleList(GetRuleList(sender, e)); //TODO:通过得到的结果,计算每一期中满足条件的个数 int[] resa = GetValue(result); double[] res = result.Select(n => ((double)n.Where(k => k).Count() / (double)n.Count())).ToArray(); for (int i = 0; i < res.Length; i++) MainForm.FilterDM.dgv.Rows[i].Cells[6].Value = res[i].ToString("F4"); MainForm.FilterDM.stausInfoShow1.SetToolInfo2("交叉验证概率(%):" + (TwoColorBall.CrossValidate(result) * 100).ToString("F4")); }); }