private void button19_Click_1(object sender, EventArgs e) { int somDim = (int)somWidth.Value; NetMining.Data.PointSet data = new PointSet(textBox4.Text); HexagonalSelfOrganizingMap hSOM = new HexagonalSelfOrganizingMap(data, somDim, 0.3); hSOM.runLargeEpochs(0.2, 1); hSOM.runLargeEpochs(0.05, 2); hSOM.runLargeEpochs(0.01, 2); //hSOM.runLargeEpochs(0.01, 4); //hSOM.runLargeEpochs(0.005, 6); //Setup out labels DelimitedFile f = new DelimitedFile(SOMLabelTextbox.Text); int labelIndex = Prompt.ShowDialog("Select Label Index", "Label File", 1, f.Data[0].Length) - 1; String[] labels = f.GetColumn(labelIndex); //Now build our array of indicies List <String> labelNames = new List <string>(); int[] labelIndexArr = new int[data.Count]; for (int i = 0; i < data.Count; i++) { if (!labelNames.Contains(labels[i])) { labelNames.Add(labels[i]); } labelIndexArr[i] = labelNames.IndexOf(labels[i]); } var bmp = hSOM.GetUMatrix(10, labelNames.Count, labelIndexArr); bmp[0].Save("test" + somDim.ToString() + ".bmp"); bmp[1].Save("count" + somDim.ToString() + ".bmp"); for (int i = 2; i < bmp.Count; i++) { bmp[i].Save("count" + somDim.ToString() + "class_" + (i - 1).ToString() + ".bmp"); } MessageBox.Show("Done!"); }
private void doSOMMapThreaded() { int w = (int)somWidth.Value; int h = (int)somHeight.Value; List <int> dim = new List <int>(); dim.Add(w); dim.Add(h); int numEpochs = (int)numericUpDown5.Value; double learningRate = (double)numericUpDown6.Value; String folder = pointSetFile.Substring(0, pointSetFile.LastIndexOf('\\')); System.IO.Directory.CreateDirectory(folder); openFileDialog2.InitialDirectory = folder; String copiedFileName = folder + "/" + pointSetFileShort; if (!File.Exists(copiedFileName)) { File.Copy(pointSetFile, copiedFileName); } PointSet somPoints = new PointSet(pointSetFile); HexagonalSelfOrganizingMap algo = new HexagonalSelfOrganizingMap(somPoints, w, learningRate); algo.runLargeEpochs(0.2, 1); algo.runLargeEpochs(0.05, 2); algo.runLargeEpochs(0.01, 2); String newCluster = folder + "/" + pointSetFileShort + "_som" + w + "x" + h + "_map_Epoch" + numEpochs + "_"; var bmp = algo.GetUMatrix(10); bmp[0].Save(newCluster + ".bmp"); bmp[1].Save(newCluster + "count" + ".bmp"); MessageBox.Show("Complete!"); }