public TemperatureMap(NNData data1) { this.AutoScroll = true; InitializeComponent(); pictureBox1.Height = 32 * data1.Length; pictureBox1.Width = 64 * data1.Num; NNData data = Check(data1); Bitmap OutputImage = new Bitmap(64 * data.Num, 32 * data.Length, System.Drawing.Imaging.PixelFormat.Format32bppArgb); Bitmap Temp = new Bitmap(64, 32, System.Drawing.Imaging.PixelFormat.Format32bppArgb); Graphics G = Graphics.FromImage(OutputImage); Graphics TempG = Graphics.FromImage(Temp); Pen BlackPen = new Pen(Color.Black, 0.3f); int TempRead = 0; for (int i = 0, j; i < data.Num; i++) { double[] arr = NNData.PartArr(data.ARR, data.Length, i); for (j = 0; j < data.Length; j++) { TempRead = (255 * data.ARR[j, i] / arr.Max() > 255) ? 255 : (int)(Math.Round(255 * data.ARR[j, i] / arr.Max())); TempG.Clear(Color.FromArgb(155, 0, TempRead, TempRead)); TempG.DrawRectangle(BlackPen, 0, 0, Temp.Width, Temp.Height); G.DrawImage(Temp, i * 64, j * 32); } } pictureBox1.Image = OutputImage; }
public static NNData Check(NNData data) { double[] min_arr = new double[data.Num]; for (int i = 0; i < data.Num; i++) { double[] arr = NNData.PartArr(data.ARR, data.Length, i); min_arr[i] = arr.Min(); } double abs_min = min_arr.Min(); if (abs_min >= 0) { return(data); } abs_min = Math.Abs(abs_min); double[,] new_arr = new double[data.Length, data.Num]; for (int i = 0; i < data.Num; i++) { for (int j = 0; j < data.Length; j++) { new_arr[j, i] = data.ARR[j, i] + abs_min + 1; } } return(new NNData(Tuple.Create(new_arr, data.Num, data.Length, data.file_name))); }
private static double[,] s0(NNData d1, NNData d2) { double[,] ret = new double[d1.Num, d2.Num]; for (int i = 0; i < ret.GetLength(0); i++) { for (int j = 0; j < ret.GetLength(1); j++) { ret[i, j] = s0_ij(NNData.PartArr(d1.ARR, d1.Length, i), NNData.PartArr(d1.ARR, d1.Length, j), NNData.PartArr(d2.ARR, d2.Length, i), NNData.PartArr(d2.ARR, d2.Length, j)); } } return(ret); }
private static double sd(NNData d) { double[] m = d.SerAr(); List <double> tmp = new List <double>(); for (int i = 0; i < d.Num; i++) { tmp.AddRange(NNData.PartArr(d.ARR, d.Length, i).Select(e => e - m[i])); } Vector v = new Vector(tmp.ToArray()); return(v * v / (d.Length - 1d)); }
public MultiCharting(NNData data) { InitializeComponent(); tableLayoutPanel1.Controls.Clear(); tableLayoutPanel1.ColumnStyles.Clear(); tableLayoutPanel1.RowStyles.Clear(); this.data = data; tableLayoutPanel1.ColumnCount = data.Num; tableLayoutPanel1.RowCount = data.Num; for (int i = 0; i < data.Num; i++) { tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100f / data.Num)); tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100f / data.Num)); } Chart[,] CHARTS = new Chart[data.Num, data.Num]; int num = 0; for (int g = 0; g < data.Num; g++) { for (int k = 0; k < data.Num; k++) { double[] part_arr = NNData.PartArr(data.ARR, data.Length, k); double min = part_arr.Min(); int numclass = korelation.num_class(part_arr); double step = (part_arr.Max() - min) / numclass; Chart chart1 = new Chart(); ChartArea chartArea1 = new ChartArea(); chartArea1.Name = "ChartArea1"; chart1.ChartAreas.Add(chartArea1); ((System.ComponentModel.ISupportInitialize)(chart1)).BeginInit(); chart1.BorderlineColor = System.Drawing.Color.Black; chart1.BorderlineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid; chart1.Size = new System.Drawing.Size(250, 200); chart1.Series.Add(num.ToString()); chart1.Series[num.ToString()].ChartArea = "ChartArea1"; chart1.Series[num.ToString()].BorderWidth = 1; chart1.Series[num.ToString()].CustomProperties = "PointWidth=1"; chart1.Series[num.ToString()].BorderColor = Color.Black; chart1.ChartAreas[0].AxisX.LabelStyle.Format = "{0:0.000}"; chart1.ChartAreas[0].AxisY.LabelStyle.Format = "{0:0.000}"; if (g == k) { chart1.ChartAreas[0].AxisX.Minimum = min; chart1.ChartAreas[0].AxisX.Maximum = part_arr.Max(); chart1.Series[num.ToString()].ChartType = SeriesChartType.Column; for (int j = 0; j < numclass; j++) { double num1 = 0; for (int i = 0; i < part_arr.Length; i++) { if ((part_arr[i] >= min) && (part_arr[i] <= (min + step + 0.00005))) { num1++; } } chart1.Series[num.ToString()].Points.AddXY(Math.Round(min + step / 2, 4), (num1 / part_arr.Length)); min = min + step; } CHARTS[k, g] = chart1; } else { chart1.Series[num.ToString()].ChartType = SeriesChartType.Point; double[] X = NNData.PartArr(data.ARR, data.Length, g); double[] Y = NNData.PartArr(data.ARR, data.Length, k); for (int i = 0; i < X.Length; i++) { chart1.Series[num.ToString()].Points.AddXY(X[i], Y[i]); } CHARTS[k, g] = chart1; } num++; } } for (int i = 0; i < data.Num; i++) { for (int j = 0; j < data.Num; j++) { tableLayoutPanel1.Controls.Add(CHARTS[i, j], i, j); } } }