public void display_confusion_matrix(Form parent_form, DataGridView dgrdv) { Form child_form = new Form(); DataGridView dgrdv_confusion = new DataGridView(); DataGridView_Helpers obj_dgrdv_helpers = new DataGridView_Helpers(); int column_index; obj_dgrdv_helpers.add_grid_column("actions", "a", dgrdv.Rows[0].Cells[0], dgrdv_confusion); for (int i = 0; i < class_regions_array.Count; i++) { column_index = i + 1; obj_dgrdv_helpers.add_grid_column("w" + column_index, "w" + column_index, dgrdv.Rows[0].Cells[0], dgrdv_confusion); } dgrdv_confusion.Rows.Add(class_regions_array.Count+1); int row_index; for (int i = 0; i < class_regions_array.Count + 1; i++) { row_index = i + 1; for (int j = 0; j < class_regions_array.Count+1; j++) { if (j == 0) dgrdv_confusion.Rows[i].Cells[j].Value = "a" + row_index; else dgrdv_confusion.Rows[i].Cells[j].Value = confusion_matrix[i, j - 1]; } } dgrdv_confusion.Location = new System.Drawing.Point(0, 0); dgrdv_confusion.Name = "dataGridView_confusion_matrix"; dgrdv_confusion.Size = new System.Drawing.Size(250, 150); child_form.Controls.Add(dgrdv_confusion); child_form.Owner = parent_form; child_form.Show(); MessageBox.Show(String.Format("Overall Accuracy ={0}", calculate_overall_accuracy())); }
public ReadTestCasesFromFile(Form parent_form, DataGridView dgrdv_meus_sigmas, DataGridView dgrdv_lambda) { obj_dgrdview_helpers = new DataGridView_Helpers(); Stream fstream = open_file_dialog(parent_form); if (fstream == null) return; dgrdv_meus_sigmas.Rows.Clear(); dgrdv_lambda.Rows.Clear(); dgrdv_lambda.Columns.Clear(); obj_dgrdview_helpers.add_grid_column("actions", "a", dgrdv_meus_sigmas.Rows[0].Cells[0], dgrdv_lambda); StreamReader sr = new StreamReader(fstream); // read first line // #_of_states_of_nature #_of_actions string line = sr.ReadLine(); if (String.IsNullOrEmpty(line)) return; String[] tokens = line.Split(' '); int num_of_states_of_nature = int.Parse(tokens[0]); int num_of_actions = int.Parse(tokens[1]); for (int i = 0; i < num_of_states_of_nature; i++) { line = sr.ReadLine(); if (String.IsNullOrEmpty(line)) return; tokens = line.Split(' '); dgrdv_meus_sigmas.Rows.Add(tokens); int col_index = i + 1; obj_dgrdview_helpers.add_grid_column("w_" + col_index, "w" + col_index, dgrdv_meus_sigmas.Rows[i].Cells[0], dgrdv_lambda); } for (int i = 0; i < num_of_actions; i++) { line = sr.ReadLine(); if (String.IsNullOrEmpty(line)) return; int row_index = i + 1; tokens = line.Split(' '); string[] row_vals = new string[tokens.Length+1]; row_vals[0] = "a" + row_index; for (int j = 0; j < tokens.Length; j++) { row_vals[j+1] = tokens[j]; } dgrdv_lambda.Rows.Add(row_vals); } }
public void display_results(DataGridView dgrdv_confusion_matrix, TextBox textbox_overall_accuracy) { textbox_overall_accuracy.Text = overall_accuracy.ToString(); DataGridView_Helpers object_data_grid_view_helpers = new DataGridView_Helpers(); object_data_grid_view_helpers.add_grid_column("actions", "/", new DataGridViewTextBoxCell(), dgrdv_confusion_matrix); for (int i = 0; i < number_of_states_of_nature; i++) { object_data_grid_view_helpers.add_grid_column(array_states_of_nature[i].label, array_states_of_nature[i].label, new DataGridViewTextBoxCell(), dgrdv_confusion_matrix); } for (int i = 0; i < number_of_states_of_nature; i++) { dgrdv_confusion_matrix.Rows.Add(array_states_of_nature[i].label); } for (int i = 0; i < number_of_states_of_nature; i++) { for (int j = 0; j < number_of_states_of_nature; j++) { dgrdv_confusion_matrix.Rows[i].Cells[j + 1].Value = confusion_matrix[i, j]; } } }