private void DrawGraph(Kmeans kmeans) { var plotName = "p" + PlotDrawCount; //Init for (int i = 0; i < kmeans.K; i++) { if (kmeans.CenterList[i].X != int.MaxValue) { chart1.Series.Add(plotName + i); chart1.Series[plotName + i].IsVisibleInLegend = false; chart1.Series[plotName + i].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; } } //plot Normal Point foreach (var p in kmeans.ClusterPoints) { chart1.Series[plotName + p.ClusterIndex].Points.AddXY(p.Point.X, p.Point.Y); } //Clusterling Average Plot for (int i = 0; i < kmeans.CenterList.Count; i++) { if (kmeans.CenterList[i].X != int.MaxValue) { chart1.Series[plotName + i].Points.AddXY(kmeans.CenterList[i].X, kmeans.CenterList[i].Y); var len = chart1.Series[plotName + i].Points.Count; chart1.Series[plotName + i].Points[len - 1].MarkerSize = 15; } } PlotDrawCount++; }
private List <Kmeans> RecursiveProcessing(Kmeans parent, List <Kmeans> register) { var child1 = new Kmeans(_k, parent.ClusterPoints.Where(x => x.ClusterIndex == 0).Select(x => x.Point).ToList()); var child2 = new Kmeans(_k, parent.ClusterPoints.Where(x => x.ClusterIndex == 1).Select(x => x.Point).ToList()); child1.Calculation(1); child2.Calculation(1); if (parent.CenterDistDispersion[0] > child1.CenterDistDispersion[0] + child1.CenterDistDispersion[1] // if( parent.BICs[0] > child1.BICs[0] + child1.BICs[1] && child1.ClusterPoints.Count > 1) { RecursiveProcessing(child1, register); } else { register.Add(child1); } if (parent.CenterDistDispersion[1] > child2.CenterDistDispersion[0] + child2.CenterDistDispersion[1] // if(parent.BICs[1] > child2.BICs[0] + child2.BICs[1] && child2.ClusterPoints.Count > 1) { RecursiveProcessing(child2, register); } else { register.Add(child2); } return(register); }
public Xmeans(List <Point> points) { TopKm = new Kmeans(_k, points); }
private List<Kmeans> RecursiveProcessing(Kmeans parent, List<Kmeans> register) { var child1 = new Kmeans(_k, parent.ClusterPoints.Where(x => x.ClusterIndex == 0).Select(x => x.Point).ToList()); var child2 = new Kmeans(_k, parent.ClusterPoints.Where(x => x.ClusterIndex == 1).Select(x => x.Point).ToList()); child1.Calculation(1); child2.Calculation(1); if (parent.CenterDistDispersion[0] > child1.CenterDistDispersion[0] + child1.CenterDistDispersion[1] // if( parent.BICs[0] > child1.BICs[0] + child1.BICs[1] && child1.ClusterPoints.Count > 1) { RecursiveProcessing(child1, register); } else register.Add(child1); if (parent.CenterDistDispersion[1] > child2.CenterDistDispersion[0] + child2.CenterDistDispersion[1] // if(parent.BICs[1] > child2.BICs[0] + child2.BICs[1] && child2.ClusterPoints.Count > 1) { RecursiveProcessing(child2, register); } else register.Add(child2); return register; }
public Xmeans(List<Point> points) { TopKm = new Kmeans(_k, points); }