protected void btnOut_Click(object sender, EventArgs e) { double Symptom = double.Parse(ddlSymptom.SelectedValue); double Job = double.Parse(ddlJob.SelectedValue); /* * 打喷嚏--1 * 头痛--2 * * 护士--1 * 农夫--2 * 建筑工人--3 * 教师--4 */ //training data DataTable table = new DataTable(); table.Columns.Add("disease"); table.Columns.Add("symptom", typeof(double)); table.Columns.Add("job", typeof(double)); table.Rows.Add("感冒", 1, 1); table.Rows.Add("过敏", 1, 2); table.Rows.Add("脑震荡", 2, 3); table.Rows.Add("感冒", 2, 3); table.Rows.Add("感冒", 1, 4); table.Rows.Add("脑震荡", 2, 4); NaiveBayes classifier = new NaiveBayes(); classifier.TrainClassifier(table); Response.Write(classifier.Classify(new double[] { Symptom, Job }));//新来了打喷嚏的建筑工人,问可能得什么病 }