private void buttonXDataDiscretizationDataView_Click(object sender, EventArgs e) { if ((datasetTempTA.CountRows() as int?) == 0) { DataTable newDataSet = datasetTA.GetData(); DiabetesDataSet.DataSetTempDataTable dataSetTempDataTable = new DiabetesDataSet.DataSetTempDataTable(); foreach (DataRow dtRow in newDataSet.Rows) { var row = dataSetTempDataTable.NewDataSetTempRow(); row["MaBn"] = Convert.ToDecimal(dtRow["MaBn"]); decimal TuoiHienTai = DateTime.Now.Year - Convert.ToDecimal(dtRow["NamSinh"]); row["Tuoi"] = DiscretizationData.RoiRacHoaTuoi(TuoiHienTai); row["GioiTinh"] = dtRow["GioiTinh"].ToString(); row["Cholesterol"] = dtRow["Cholesterol"].ToString(); row["HDL_Cholesterol"] = dtRow["HDL_Cholesterol"].ToString(); row["Triglyceride"] = dtRow["Triglyceride"].ToString(); row["LDL_Cholesterol"] = dtRow["LDL_Cholesterol"].ToString(); row["Glucose"] = dtRow["Glucose"].ToString(); row["SGOT"] = dtRow["SGOT"].ToString(); row["SGPT"] = dtRow["SGPT"].ToString(); row["Urea"] = dtRow["Urea"].ToString(); row["WBC"] = dtRow["WBC"].ToString(); row["LYM"] = dtRow["LYM"].ToString(); row["MONO"] = dtRow["MONO"].ToString(); row["GRAN"] = dtRow["GRAN"].ToString(); row["TyLeLYM"] = dtRow["TyLeLYM"].ToString(); row["TyLeMONO"] = dtRow["TyLeMONO"].ToString(); row["TyLeGRAN"] = dtRow["TyLeGRAN"].ToString(); row["HGB"] = dtRow["HGB"].ToString(); row["RBC"] = dtRow["RBC"].ToString(); row["HTC"] = dtRow["HTC"].ToString(); row["MCV"] = dtRow["MCV"].ToString(); row["MCH"] = dtRow["MCH"].ToString(); row["MCHC"] = dtRow["MCHC"].ToString(); row["RDW_CV"] = dtRow["RDW_CV"].ToString(); row["PLT"] = dtRow["PLT"].ToString(); row["MPV"] = dtRow["MPV"].ToString(); row["PDW"] = dtRow["PDW"].ToString(); row["PCT"] = dtRow["PCT"].ToString(); row["Na"] = dtRow["Na"].ToString(); row["K"] = dtRow["K"].ToString(); row["Cl"] = dtRow["Cl"].ToString(); row["Ca"] = dtRow["Ca"].ToString(); row["TieuDuong"] = dtRow["TieuDuong"].ToString(); dataSetTempDataTable.AddDataSetTempRow(row); //InsertDataSetTempRow(dtRow); } datasetTempTA.Update(dataSetTempDataTable); } dtDataSetTempForPreProcessing = newDataSetTempTA.GetData(); this.bindingSourcePreprocessingData.DataSource = null; this.bindingSourcePreprocessingData.DataSource = dtDataSetTempForPreProcessing; this.dataGridViewXDescriptiveData.DataSource = null; if (checkedListBoxColumnName.Items.Count > 0) { checkedListBoxColumnName.Items.Clear(); } for (int i = 3; i < dtDataSetTempForPreProcessing.Columns.Count - 1; i++) { String colName = dtDataSetTempForPreProcessing.Columns[i].ColumnName; checkedListBoxColumnName.Items.Add(colName, false); } buttonXImportDataSet.Enabled = false; buttonXDataCleanning.Enabled = false; comboBoxExDataCleanning.Enabled = false;; buttonXDiscretizationDataStatistics.Enabled = true; buttonXDataDiscretizationRun.Enabled = true; integerInputIntervalDiscretization.Enabled = true; checkBoxXDiscreteAllColumn.Enabled = true; checkedListBoxColumnName.Enabled = true; buttonXCustomDataDiscretization.Enabled = true; }
//Hàm dùng để rời rác hóa dataset trước khi thực hiện chẩn đoán public DataTable DataDiscretization(DataTable dt) { DiabetesDataSetB.TrainningDataTable trainningDataTable = new DiabetesDataSetB.TrainningDataTable(); trainningDataTable.Columns.Add("MaBn", typeof(decimal)); trainningDataTable.Columns["MaBn"].SetOrdinal(0); DataTable dtBayesObject = bayesObjectTA.GetData(); try { foreach (DataRow dtRow in dt.Rows) { DataRow newRow = trainningDataTable.NewRow(); foreach (DataColumn dtCol in dt.Columns) { String colName = dtCol.ColumnName; switch (colName) { case "ID": case "NgayKham": case "HoTen": case "GRAN": case "TyLeGRAN": case "Na": case "K": case "Cl": case "Ca": break; case "MaBn": newRow[colName] = dtRow[colName]; break; case "TieuDuong": newRow[colName] = Convert.ToBoolean(dtRow[colName]); break; case "GioiTinh": newRow[colName] = dtRow[colName].ToString(); break; case "NamSinh": int namSinh = Convert.ToInt16(dtRow[colName]); int tuoiHienTai = DateTime.Now.Year - namSinh; String Tuoi = DiscretizationData.RoiRacHoaTuoi(tuoiHienTai); newRow["Tuoi"] = Tuoi; break; default: decimal colValue = Convert.ToDecimal(dtRow[colName]); String giaTriRoiRac = DiscretizationData.DataDiscretizationForDiagnosis(colValue, colName); newRow[colName] = giaTriRoiRac; break; } } trainningDataTable.Rows.Add(newRow); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return(trainningDataTable); }