public ModelEventArgs(string a, KmeansStore s, KmeansEvaluate e, KmeansConfig c) { this.action = a; this.store = s; this.config = c; this.evaluate = e; }
public ModelEventArgs(String a, List <DataV2> dt, List <Cluster> dc, KmeansConfig c) { this.action = a; this.dataTotal = dt; this.dataClusters = dc; this.config = c; }
public KmeansModel() { this.store = new KmeansStore(); this.config = new KmeansConfig(); this.evaluate = new KmeansEvaluate(); this.status = new KmeansStatus(this.config); }
public static double SSE(KmeansConfig config, Cluster[] clusters) { double sse = 0; for (int k = 0; k < config.K; k++) { for (int i = 0; i < clusters[k].instances.Count; i++) { sse += Math.Pow(Distance(clusters[k].timeslot, clusters[k].instances[i].timeslot), 2); } } return(sse); }
public void DrawGraph(KmeansConfig config, Cluster[] clusters) { for (int k = 0; k < config.K; k++) { EnergyGraph e = (EnergyGraph)tableLayoutPanel1.Controls[k]; e.cluster = clusters[k]; /* * if (!checkBox_repaint.Checked) * continue; */ e.drawBitmap(); e.Invalidate(); } }
public static double ECV(KmeansConfig config, Cluster[] clusters, DataV2[] datas) { double[] mean = new double[config.energyLength]; Parallel.For(0, mean.Length, (e) => { for (int d = 0; d < datas.Length; d++) { mean[e] += datas[d].timeslot[e]; } mean[e] /= datas.Length; }); double TSS = 0; // Total Sum of Squares double WSS = 0; // Within cluster Sum of Squares for (int d = 0; d < datas.Length; d++) { TSS += Math.Pow(Distance(datas[d].timeslot, mean), 2); WSS += Math.Pow(Distance(datas[d].timeslot, clusters[datas[d].mainCluster].timeslot), 2); } return(1 - WSS / TSS); }
public void ReadyTables(KmeansConfig config, DataV2[] datas) { EnergyGraph.setHigh(datas); tableLayoutPanel1.SuspendLayout(); tableLayoutPanel1.RowCount = tableLayoutPanel1.ColumnCount = (int)config.grid + (config.grid == (int)config.grid ? 0 : 1); for (int i = tableLayoutPanel1.RowStyles.Count; i < tableLayoutPanel1.RowCount; i++) { tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100)); tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); } while (tableLayoutPanel1.Controls.Count != tableLayoutPanel1.RowCount * tableLayoutPanel1.ColumnCount) { tableLayoutPanel1.Controls.Add(new EnergyGraph()); } for (int c = 0; c < tableLayoutPanel1.Controls.Count; c++) { aProp.SetValue(tableLayoutPanel1.Controls[c], true, null); } tableLayoutPanel1.ResumeLayout(); EnergyGraph.totalDataLength = datas.Length; }
public ModelEventArgs(string a, KmeansStore s, KmeansConfig c) { this.action = a; this.store = s; this.config = c; }
private void DrawUIDGraph(List <DataV2> dataTotal, List <Cluster> dataClusters, KmeansConfig config) { EnergyGraph.totalDataLength = dataTotal.Count; for (int k = 0; k < config.K; k++) { (tableLayoutPanel1.Controls[k] as EnergyGraph).cluster = dataClusters[k]; (tableLayoutPanel1.Controls[k] as EnergyGraph).drawBitmap(); (tableLayoutPanel1.Controls[k] as EnergyGraph).Invalidate(); } if (dataTotal.Count == 0) { return; } }