private void KFunctionForm_Load(object sender, EventArgs e) { #region 数据初始化 IList testSampleList = FeatureHelper.GetTestFeaturesList(); //获取原始测试 KnNear kn = new KnNear(); //每个元素都存储在 KeyValuePair<TKey, TValue> 对象中 IDictionary <int, double> map = new Dictionary <int, double>(); //每个元素都存储在DictionaryEntry IDictionary dictionary = new Hashtable(); //DictionaryEntry进行循环遍历 ArrayList klist = new ArrayList(); ArrayList ratelist = new ArrayList(); #endregion #region 获取K和识别率 for (int k = 1; k < 50; k += 2) { int testResult = 0; double correctCount = 0; double correctRate = 0.0; foreach (Features feature in testSampleList) { testResult = kn.DoK_nearest(feature, FeatureHelper.GetFeaturesList(), k); if (testResult > 0) { //检查结果是否正确 if (testResult == feature.classID) { correctCount++; } } } correctRate = (correctCount / Convert.ToDouble(testSampleList.Count)) * 100.0; map.Add(k, correctRate / 10); klist.Add(k); ratelist.Add(correctRate * 2); } #endregion #region 显示点图 PreviewFunctionImage(klist, ratelist); #endregion }
public YTDomain(IRow pRow) { _id = pRow.OID; _name = FeatureHelper.GetRowValue(pRow, "DomainName").ToString(); _description = FeatureHelper.GetRowValue(pRow, "DomainDescription").ToString(); _domainValues = FeatureHelper.GetRowValue(pRow, "DomainValues").ToString(); if (string.IsNullOrEmpty(_domainValues)) { _valuePairs = new List <YTDomainValue>(); } else { _valuePairs = JsonConvert.DeserializeObject <List <YTDomainValue> >(_domainValues); } }
// 重置相关结果视图 private void ResetResultView() { classChooseComboBox.Items.Clear(); classFeatureList = MVHelper.GetClassFeatureList(FeatureHelper.GetFeaturesList()); //按照类列表中的内容,生成类选择下拉列表的项目 for (int i = 0; i < classFeatureList.Count; i++) { Sample sample = (Sample)classFeatureList[i]; string classIDStr = "000" + sample.ClassID; classChooseComboBox.Items.Add(classIDStr.Substring(classIDStr.Length - 3)); } //初始选择 classChooseComboBox.SelectedIndex = 0; //计算初始选择的结果 ShowResultView(Int32.Parse((string)this.classChooseComboBox.Items[0])); }
public YTField(IRow pRow) { _id = pRow.OID; _name = FeatureHelper.GetRowValue(pRow, "FieldName").ToString(); _aliasName = FeatureHelper.GetRowValue(pRow, "AliasName").ToString(); _length = ConvertHelper.ObjectToInt(FeatureHelper.GetRowValue(pRow, "FieldLength")); _precision = ConvertHelper.ObjectToInt(FeatureHelper.GetRowValue(pRow, "FieldPrecision")); _fieldTypeName = FeatureHelper.GetRowValue(pRow, "FieldType").ToString(); _fieldType = FieldHelper.ConvertFromSimpleString(_fieldTypeName); string allowNullStr = FeatureHelper.GetRowValue(pRow, "AllowNull").ToString(); _allowNull = string.IsNullOrEmpty(allowNullStr) || allowNullStr.ToUpper().StartsWith("T") || allowNullStr == "真"; string keyStr = FeatureHelper.GetRowValue(pRow, "IsKey").ToString(); _isKey = string.IsNullOrEmpty(keyStr) == false || (keyStr.ToUpper().StartsWith("T") == true ? true : false); _domain = FeatureHelper.GetRowValue(pRow, "FieldDomain").ToString(); _defaultValue = FeatureHelper.GetRowValue(pRow, "DefaultValue").ToString(); }
public void Load(IFeature pFeature, string nameField) { _boundary = pFeature.Shape; string pName = FeatureHelper.GetFeatureStringValue(pFeature, nameField); PageName = pName; _autoElements.Clear(); for (int i = 0; i < pFeature.Fields.FieldCount; i++) { IField pField = pFeature.Fields.Field[i]; if (pField.Type == esriFieldType.esriFieldTypeGeometry) { continue; } string pValue = FeatureHelper.GetFeatureStringValue(pFeature, pField.Name); _autoElements.Add(new PrintPageElement(pField.Name, pField.AliasName, pValue)); } }
public void GetMedianFeature_Works_As_Expected() { var features = new List <Feature>(); features.Add(new Feature("place1", 1, 2)); features.Add(new Feature("place2", 2, 2)); features.Add(new Feature("place3", 3, 2)); features.Add(new Feature("place4", 4, 2)); features.Add(new Feature("place5", 5, 2)); features.Add(new Feature("place6", 6, 2)); features.Add(new Feature("place7", 7, 2)); //sort by X in test but Y is also used during building process features = features.OrderBy(i => i.X).ToList(); var medianFeature = FeatureHelper.GetMedianFeatureFromList(features); Assert.Equal("place4", medianFeature.Name); }
public void Setup() { testDbContext = Substitute.For <IDbDataContext>(); testUserService = Substitute.For <IUserService>(); pageService = new PageService(testDbContext, testUserService); mockedPage = PageHelper.Create(); mockedUser = UserHelper.Create(); mockedUser.Accesses = new List <UserAccess>(); mockedFeatures = FeatureHelper.CreateList(3); FeatureHelper.CreateFeatureAccess(mockedFeatures, mockedPage, mockedUser, AccessType.None); mockedPage.Features = mockedFeatures; testUserService.GetUserByUserName(mockedUser.UserName).Returns(mockedUser); mockedPage.PageName = "Index"; mockedPages = new List <Page>() { mockedPage }.AsQueryable(); testDbContext.Pages.Returns(mockedPages); }
public void BuildTree(KDNode currentNode, List <Feature> features, bool useXAxis) { if (useXAxis) { features = features.OrderBy(i => i.X).ToList(); } else { features = features.OrderBy(i => i.Y).ToList(); } Feature med = FeatureHelper.GetMedianFeatureFromList(features); var node = InsertNode(currentNode, med, true); var splitFeatures = FeatureHelper.SplitFeatures(features, features.IndexOf(med)); List <Feature> leftSplit = splitFeatures[0].ToList(); List <Feature> rightSplit = splitFeatures[1].ToList(); if (leftSplit.Count <= 1) { if (leftSplit.Count == 1) { InsertNode(node, leftSplit[0], useXAxis); } } else { this.BuildTree(node, leftSplit, !useXAxis); //alternate dimension each level we build } // Do the same for the right points if (rightSplit.Count <= 1) { if (rightSplit.Count == 1) { InsertNode(node, rightSplit[0], useXAxis); } } else { BuildTree(node, rightSplit, !useXAxis); } }
public void UpdateRow(IRow pRow) { pRow.Value[pRow.Fields.FindField("TemplateName")] = _name; pRow.Value[pRow.Fields.FindField("AliasName")] = _aliasName; pRow.Value[pRow.Fields.FindField("BaseName")] = _baseName; pRow.Value[pRow.Fields.FindField("Dataset")] = _datasetName; pRow.Value[pRow.Fields.FindField("FeatureType")] = FeatureHelper.ConvertTypeToSimpleString(_featureType); pRow.Value[pRow.Fields.FindField("GeometryType")] = GeometryHelper.ConvertToString(_geometryType); if (_fields.Count == 0) { pRow.Value[pRow.Fields.FindField("FieldDefs")] = ""; } else { pRow.Value[pRow.Fields.FindField("FieldDefs")] = JsonConvert.SerializeObject(_fields); } pRow.Store(); _id = pRow.OID; }
//均值u和协方差∑计算 private void meanToolStripMenuItem_Click(object sender, EventArgs e) { this.sampleArray = FeatureHelper.GetFeaturesList(); if (sampleArray == null || sampleArray.Count == 1) { MessageBox.Show(this, "还没有提取特征值,请按步骤来", "提示信息", MessageBoxButtons.OK); } else { MeanCalculateForm mcform = new MeanCalculateForm(); mcform.ShowDialog(); } #region 测试 //MeanCalculateForm mcform = new MeanCalculateForm(); //mcform.ShowDialog(); #endregion }
// 判断K值的合法性 public bool KCheck(int k) { if (FeatureHelper.GetFeaturesList().Count == FeatureHelper.GetTestFeaturesList().Count) { MessageBox.Show(this, "Kn近邻法首先进行开测试进行样本提取", "提示信息", MessageBoxButtons.OK); return(false); } if (k % 2 == 0) { MessageBox.Show(this, "K 值必须是奇数!", "提示信息", MessageBoxButtons.OK); return(false); } if (k < 1 || k > 49) { MessageBox.Show(this, "K 值必须在 1 到 49 之间!", "提示信息", MessageBoxButtons.OK); return(false); } return(true); }
/// <summary> /// Executes the specified command. /// </summary> /// <param name="command">The command.</param> /// <param name="keyValues">The key values.</param> /// <param name="output">The output.</param> /// <returns></returns> public override int Execute(string command, StringDictionary keyValues, out string output) { output = string.Empty; Logger.Verbose = true; ActivationScope scope = ActivationScope.Feature; if (Params["scope"].UserTypedIn) { scope = (ActivationScope)Enum.Parse(typeof(ActivationScope), Params["scope"].Value.ToLowerInvariant(), true); } bool force = Params["force"].UserTypedIn; bool ignoreNonActive = Params["ignorenonactive"].UserTypedIn; if (ignoreNonActive) { force = true; } string url = null; if (Params["url"].UserTypedIn) { url = Params["url"].Value.TrimEnd('/'); } try { Logger.Write("Started at {0}", DateTime.Now.ToString()); Guid featureId = FeatureHelper.GetFeatureIdFromParams(Params); FeatureHelper fh = new FeatureHelper(); fh.ActivateDeactivateFeatureAtScope(scope, featureId, false, url, force, ignoreNonActive); } finally { Logger.Write("Finished at {0}\r\n", DateTime.Now.ToString()); } return((int)ErrorCodes.NoError); }
public XmlNode ToXml(XmlDocument doc) { XmlNode templateNode = doc.CreateElement("Template"); XmlAttribute nameAttribute = doc.CreateAttribute("Name"); nameAttribute.Value = _name; templateNode.Attributes.Append(nameAttribute); nameAttribute = doc.CreateAttribute("AliasName"); nameAttribute.Value = _aliasName; templateNode.Attributes.Append(nameAttribute); nameAttribute = doc.CreateAttribute("BaseName"); nameAttribute.Value = _baseName; templateNode.Attributes.Append(nameAttribute); nameAttribute = doc.CreateAttribute("Dataset"); nameAttribute.Value = _datasetName; templateNode.Attributes.Append(nameAttribute); nameAttribute = doc.CreateAttribute("FeatureType"); nameAttribute.Value = FeatureHelper.ConvertTypeToSimpleString(_featureType); templateNode.Attributes.Append(nameAttribute); nameAttribute = doc.CreateAttribute("GeometryType"); nameAttribute.Value = GeometryHelper.ConvertToString(_geometryType); templateNode.Attributes.Append(nameAttribute); XmlNode fieldsNode = doc.CreateElement("Fields"); foreach (IYTField ytField in _fields) { fieldsNode.AppendChild(ytField.ToXml(doc)); } templateNode.AppendChild(fieldsNode); return(templateNode); }
public (string Prediction, float Score) Classify(TextBlock textBlock, IEnumerable <PdfPath> paths, IEnumerable <IPdfImage> images, double averagePageFontHeight, List <DocumentBookmarkNode> pageBookmarksNodes) { double bboxArea = textBlock.BoundingBox.Area; var letters = textBlock.TextLines.SelectMany(li => li.Words).SelectMany(w => w.Letters); var features = FeatureHelper.GetFeatures( textBlock, paths, images, averagePageFontHeight, textBlock.BoundingBox.Area, pageBookmarksNodes); BlockFeatures blockFeatures = new BlockFeatures() { BlockAspectRatio = features[0], CharsCount = features[1], WordsCount = features[2], LinesCount = features[3], PctNumericChars = features[4], PctAlphabeticalChars = features[5], PctSymbolicChars = features[6], PctBulletChars = features[7], DeltaToHeight = features[8], PathsCount = features[9], PctBezierPaths = features[10], PctHorPaths = features[11], PctVertPaths = features[12], PctOblPaths = features[13], ImagesCount = features[14], ImageAvgProportion = features[15], BestNormEditDistance = features[16], }; var result = predEngine.Predict(blockFeatures); return(FeatureHelper.Categories[(int)result.Prediction], result.Score.Max()); }
protected override void UpdateDataObject() { SPFeatureDefinition featureDef = null; ActivationScope scope = ActivationScope.Feature; if (ActivateAtScope.HasValue) { scope = ActivateAtScope.Value; } if (farmLevelFeature) { featureDef = SPFarm.Local.FeatureDefinitions[base.DataObject.Id]; } else { featureDef = base.DataObject; } try { Logger.Write("Started at {0}", DateTime.Now.ToString()); Guid featureId = featureDef.Id; FeatureHelper fh = new FeatureHelper(); fh.ActivateDeactivateFeatureAtScope(featureDef, scope, true, Url, Force.IsPresent, IgnoreNonActive.IsPresent); } finally { Logger.Write("Finished at {0}\r\n", DateTime.Now.ToString()); } if ((featureDef != null) && (PassThru.IsPresent)) { base.DataObject = featureDef; base.WriteResult(base.DataObject); } }
public void SplitFeatureList_Works_As_Expected() { var features = new List <Feature>(); features.Add(new Feature("place1", 1, 2)); features.Add(new Feature("place2", 2, 2)); features.Add(new Feature("place3", 3, 2)); features.Add(new Feature("place4", 4, 2)); features.Add(new Feature("place5", 5, 2)); features.Add(new Feature("place6", 6, 2)); features.Add(new Feature("place7", 7, 2)); var expectedList1 = new List <Feature>(); expectedList1.Add(new Feature("place1", 1, 2)); expectedList1.Add(new Feature("place2", 2, 2)); expectedList1.Add(new Feature("place3", 3, 2)); var expectedList2 = new List <Feature>(); expectedList2.Add(new Feature("place5", 5, 2)); expectedList2.Add(new Feature("place6", 6, 2)); expectedList2.Add(new Feature("place7", 7, 2)); var outcomeLists = FeatureHelper.SplitFeatures(features, 3); for (int i = 0; i < outcomeLists[0].Count; i++) { Assert.Equal(outcomeLists[0][i].Name, expectedList1[i].Name); } for (int i = 0; i < outcomeLists[1].Count; i++) { Assert.Equal(outcomeLists[1][i].Name, expectedList2[i].Name); } }
public List <FeatureNode> Build() { var result = new List <FeatureNode>(); var parentFeatures = FeatureHelper.GetFeaturesWithType(FeatureType.Parent); foreach (var parentFeature in parentFeatures) { var parentInfo = FeatureInfo.Builder.Build(parentFeature, FeatureType.Parent); var parentNode = new FeatureNode(parentInfo); foreach (var childFeature in FeatureHelper.GetChildFeatures(parentFeature)) { var childInfo = FeatureInfo.Builder.Build(childFeature, FeatureType.Child); var childNode = new FeatureNode(childInfo, parentNode); parentNode.Nodes.Add(childNode); } result.Add(parentNode); } return(result); }
public double FindDistanceToNearestNeighbour(KDNode currentNode, Feature goalFeature, KDNode closestNeighbour, double closestNeighbourDistance) { if (currentNode == null) { return(closestNeighbourDistance); } var currentDistance = FeatureHelper.GetDistance(currentNode.Feature, goalFeature); if (currentDistance < closestNeighbourDistance) { if (currentNode.Feature != goalFeature) { closestNeighbour = currentNode; closestNeighbourDistance = currentDistance; } } if (currentNode.UseXAxis) { if (goalFeature.X < currentNode.Feature.X) //is goal.x LEFT current node.x? IF so, traverse LEFT, otherwise go RIGHT (easy to understand because this is X comparison node) { closestNeighbourDistance = FindDistanceToNearestNeighbour(currentNode.LeftNode, goalFeature, closestNeighbour, closestNeighbourDistance); if (Math.Abs(currentNode.Feature.X - goalFeature.X) < closestNeighbourDistance) { closestNeighbourDistance = FindDistanceToNearestNeighbour(currentNode.RightNode, goalFeature, closestNeighbour, closestNeighbourDistance); } } else { closestNeighbourDistance = FindDistanceToNearestNeighbour(currentNode.RightNode, goalFeature, closestNeighbour, closestNeighbourDistance); if (Math.Abs(goalFeature.X - currentNode.Feature.X) < closestNeighbourDistance) { closestNeighbourDistance = FindDistanceToNearestNeighbour(currentNode.LeftNode, goalFeature, closestNeighbour, closestNeighbourDistance); } } } else { if (goalFeature.Y > currentNode.Feature.Y) //is goal.y ABOVE current node.y? IF so, traverse to RIGHT to go ABOVE (because this is a Y comparison node) otherwise go left to look down { closestNeighbourDistance = FindDistanceToNearestNeighbour(currentNode.RightNode, goalFeature, closestNeighbour, closestNeighbourDistance); if (Math.Abs(currentNode.Feature.Y - goalFeature.Y) < closestNeighbourDistance) { closestNeighbourDistance = FindDistanceToNearestNeighbour(currentNode.LeftNode, goalFeature, closestNeighbour, closestNeighbourDistance); } } else { closestNeighbourDistance = FindDistanceToNearestNeighbour(currentNode.LeftNode, goalFeature, closestNeighbour, closestNeighbourDistance); if (Math.Abs(goalFeature.Y - currentNode.Feature.Y) < closestNeighbourDistance) { closestNeighbourDistance = FindDistanceToNearestNeighbour(currentNode.RightNode, goalFeature, closestNeighbour, closestNeighbourDistance); } } } return(closestNeighbourDistance); }
// 分类运算 private void classifyButton_Click(object sender, EventArgs e) { //前提检验 if (SelectedPCXHelper.GetSelPCXFromLB().Count == 0 || SelectedPCXHelper.GetUnselPCXList().Count == 0) { MessageBox.Show(this, "您还未提取样本特征,或者还未设置测试样本集!", "提示信息", MessageBoxButtons.OK); } else { string correctRate = null; //正确率 string myfilepath = filepathText.Text.ToString(); Features feature; #region 这里做一个文件名为unknown.pcx的判断 string filename = FeatureHelper.GetUnknownName(myfilepath); if (filename.ToLower().Equals("unknown")) { feature = new Features(myfilepath); } else { int classID = Convert.ToInt32(FeatureHelper.GetUpperFoldername(myfilepath)); feature = new Features(myfilepath, classID); } #endregion #region Bayes分类法 if (rbBayes.Checked) { #region 数据初始化 CheckInit(); double correctCount = 0.0; #endregion IList sampleList = FeatureHelper.GetFeaturesList(); //获取原始训练样本 //从降维器获取降维后的新样本 IList newSampleList = MDAHelper.GetMDSampleList(); MVHelper.SetSampleList((ArrayList)newSampleList); Bayes bayes = Bayes.GetInstance(); bayes.TrainSampleList = newSampleList; //向贝叶斯分类器注入降维后的训练样本 //int classID = Convert.ToInt32(FeatureHelper.GetUpperFoldername(myfilepath)); //Features feature = new Features(myfilepath, classID); feature = MDAHelper.MDSample(feature); //测试样本降维 int testClassID = bayes.DecisionFunction(feature); //用贝叶斯决策进行测试样本分类 //结果显示 lblunknownclassify.Text = testClassID.ToString("000"); if (feature.classID == testClassID) { lblerrorinfo.Text = "Bayes分类法分类正确"; lblerrorinfo.ForeColor = Color.Green; } //unknown.pcx处理 else if (feature.classID == -1) { } else { lblerrorinfo.Text = "Bayes分类法分类失败"; lblerrorinfo.ForeColor = Color.Green; } } #endregion #region Kn近邻法 if (rbKn.Checked) { #region 相关数据初始化 CheckInit(); int testResult = -1; double correctCount = 0.0; int kvalue = Constant.kvalue; #endregion #region 效的情况下进行计算 if (KCheck(kvalue)) { KnNear my_knearest = new KnNear(); //int classID = Convert.ToInt32(FeatureHelper.GetUpperFoldername(myfilepath)); //Features currfeature = new Features(myfilepath, classID); testResult = my_knearest.DoK_nearest(feature, FeatureHelper.GetFeaturesList(), kvalue); //testResult为K近邻的分类结果 // 其实testResult的结果直接就是result求的值 string result = testResult.ToString("000"); lblunknownclassify.Text = result; result = ResultConvert(result); int testID = Convert.ToInt32(result); if (testID > 0 && testID == feature.classID) { //correctRate = "分类正确率: " + Constant.kn_Rate; lblerrorinfo.Text = "Kn近邻法分类正确"; lblerrorinfo.ForeColor = Color.Green; } //unknown.pcx处理 else if (feature.classID == -1) { } else { lblerrorinfo.Text = "Kn近邻法分类失败!"; lblerrorinfo.ForeColor = Color.Green; } } #endregion } #endregion #region 最近邻法 if (rbnearest.Checked) { #region 初始化 CheckInit(); int testResult = -1; double correctCount = 0.0; #endregion #region 最近邻分类 if (NearestCheck()) { Nearest nearest = new Nearest(); //int classID = Convert.ToInt32(FeatureHelper.GetUpperFoldername(myfilepath)); //Features currfeature = new Features(myfilepath, classID); testResult = nearest.Do_Nearest(feature, FeatureHelper.GetFeaturesList()); string result = testResult.ToString("000"); lblunknownclassify.Text = result; if (testResult > 0 && testResult == feature.classID) { lblerrorinfo.Text = "最近邻法分类正确"; lblerrorinfo.ForeColor = Color.Green; } //unknown.pcx处理 else if (feature.classID == -1) { } else { lblerrorinfo.Text = "最近邻法分类失败!"; lblerrorinfo.ForeColor = Color.Green; } } #endregion } #endregion } }
public FeatureWithObserver(string name) : base(FeatureHelper.GetUnnamed(name)) { FeatureHelper.CollectSystems(this.name, this); Object.DontDestroyOnLoad(this.gameObject); }
private void testButton_Click(object sender, EventArgs e) { #region 数据初始化 double correctCount = 0.0; double correctRate = 0.0; IList sampleList = FeatureHelper.GetFeaturesList(); //获取原始训练样本 //从降维器获取降维后的新样本 IList newSampleList = MDAHelper.GetMDSampleList(); MVHelper.SetSampleList((ArrayList)newSampleList); Bayes bayes = Bayes.GetInstance(); bayes.TrainSampleList = newSampleList; //向贝叶斯分类器注入降维后的训练样本 IList testSampleList = FeatureHelper.GetTestFeaturesList(); //获取测试样本 #endregion #region DataGridView操作 bayesDataGridView.DataSource = null; bayesDataGridView.Rows.Clear(); bayesDataGridView.Refresh(); DataSet ds = new DataSet(); DataTable dt = new DataTable(); // 或者直接将arr作为参数传入 //FeatureHelper.GetSamplesFeatures(); //初始化训练和测试样本 dt.Columns.Add("文件夹", typeof(string)); dt.Columns.Add("所属类别", typeof(string)); dt.Columns.Add("测试类别", typeof(string)); dt.Columns.Add("正误判断", typeof(string)); for (int i = 0; i < testSampleList.Count; i++) { DataRow row = dt.NewRow(); string rightOrWrong = "×"; Features feature = (Features)testSampleList[i]; row[0] = feature.Filepath; row[1] = feature.classID; feature = MDAHelper.MDSample(feature); //测试样本降维 int testClassID = bayes.DecisionFunction(feature); //用贝叶斯决策进行测试样本分类 // 用StringBuilder加快字符串处理速度。【值类型和堆类型】 StringBuilder sb = new StringBuilder(); sb.Append("类"); sb.Append(testClassID.ToString()); sb.ToString(); row[2] = sb; if (feature.classID == testClassID) { correctCount++; row[3] = " "; } else { row[3] = rightOrWrong; //this.bayesDataGridView.DefaultCellStyle.ForeColor = Color.Red; } dt.Rows.Add(row); } ds.Tables.Add(dt); this.bayesDataGridView.DataSource = ds.Tables[0]; #endregion #region Bayes分类性能显示 correctRate = (correctCount / Convert.ToDouble(testSampleList.Count)) * 100.0; Constant.bayes_Rate = correctRate.ToString("0.000") + "%"; dataShowLabel.Text = "测试样本总数 " + testSampleList.Count + " ,Bayes判断正确 " + correctCount + " 个,正确率为:" + Constant.bayes_Rate; #endregion }
// 获取Dataset数据 public DataSet GetViewDS(out double ccount, out double crate, out int count) { #region 数据初始化 double correctCount = 0; double correctRate = 0.0; int testResult = 0; Nearest nearest = new Nearest(); IList testSampleList = FeatureHelper.GetTestFeaturesList(); //获取原始测试 #endregion #region DataGridView操作 dgv_result.DataSource = null; dgv_result.Rows.Clear(); dgv_result.Refresh(); DataSet ds = new DataSet(); DataTable dt = new DataTable(); dt.Columns.Add("样本路径", typeof(string)); dt.Columns.Add("样本类", typeof(string)); dt.Columns.Add("样本测试结果类", typeof(string)); dt.Columns.Add("正误判断", typeof(string)); foreach (Features feature in testSampleList) { testResult = nearest.Do_Nearest(feature, FeatureHelper.GetFeaturesList()); if (testResult > 0) { DataRow row = dt.NewRow(); string rightOrWrong = "×"; row[0] = feature.Filepath; row[1] = feature.classID; row[2] = string.Format("类{0}", testResult); //检查结果是否正确 if (testResult == feature.classID) { correctCount++; row[3] = " "; } else { row[3] = rightOrWrong; //this.knDataGridView.DefaultCellStyle.ForeColor = Color.Red; } dt.Rows.Add(row); } } ds.Tables.Add(dt); //this.dgv_result.DataSource = ds.Tables[0]; //SetControlPropertyValue(dgv_result, "DataSource", ds.Tables[0]); #endregion #region Kn近邻法性能显示 //correctRate = (correctCount / Convert.ToDouble(testSampleList.Count)) * 100.0; //Constant.kn_Rate = correctRate.ToString("0.000") + "%"; //lbl_result.Text = "测试样本总数 " + testSampleList.Count + " ,Kn近邻法判断正确 " // + correctCount + " 个,正确率为:" + Constant.kn_Rate; #endregion ccount = correctCount; crate = correctRate; count = testSampleList.Count; return(ds); }
private void Init(string name) { FeatureHelper.CollectSystems(name, this); }
protected override async void OnClick() { var success = await QueuedTask.Run(() => FeatureHelper.GetTopologyFeatureLayers().GenerateRandomPolygons()); Debug.WriteLine($"Created topology features? {success}"); }
// 测试启动 private void knTestButton_Click(object sender, EventArgs e) { int kvalue = Convert.ToInt32(kValueText.Text); Constant.kvalue = kvalue; #region K有效的情况下进行计算 if (KCheck(kvalue)) { #region 数据初始化 double correctCount = 0; double correctRate = 0.0; int testResult = 0; KnNear my_knearest = new KnNear(); IList testSampleList = FeatureHelper.GetTestFeaturesList(); //获取原始测试 #endregion #region DataGridView操作 knDataGridView.DataSource = null; knDataGridView.Rows.Clear(); knDataGridView.Refresh(); DataSet ds = new DataSet(); DataTable dt = new DataTable(); dt.Columns.Add("样本路径", typeof(string)); dt.Columns.Add("样本测试结果类", typeof(string)); dt.Columns.Add("所取K值", typeof(string)); dt.Columns.Add("正误判断", typeof(string)); foreach (Features feature in testSampleList) { testResult = my_knearest.DoK_nearest(feature, FeatureHelper.GetFeaturesList(), kvalue); if (testResult > 0) { DataRow row = dt.NewRow(); string rightOrWrong = "×"; row[0] = feature.Filepath; row[1] = string.Format("类{0}", testResult); row[2] = kvalue; //检查结果是否正确 if (testResult == feature.classID) { correctCount++; row[3] = " "; } else { row[3] = rightOrWrong; //this.knDataGridView.DefaultCellStyle.ForeColor = Color.Red; } dt.Rows.Add(row); } } ds.Tables.Add(dt); this.knDataGridView.DataSource = ds.Tables[0]; #endregion #region Kn近邻法性能显示 correctRate = (correctCount / Convert.ToDouble(testSampleList.Count)) * 100.0; Constant.kn_Rate = correctRate.ToString("0.000") + "%"; resultLabel.Text = "测试样本总数 " + testSampleList.Count + " ,Kn近邻法判断正确 " + correctCount + " 个,正确率为:" + Constant.kn_Rate; #endregion } #endregion }
/// Constructor, name could be empty/null for noname systems public Feature(string name) { name = FeatureHelper.GetUnnamed(name); FeatureHelper.CollectSystems(name, this); }
private void exitButton_Click(object sender, EventArgs e) { FeatureHelper.Close(); this.Close(); }