public void Algorithm02TestFromPublication() { var table = new FuzzyTable(); output.WriteLine("Algorithm02TestFromPublication STARTED"); try { // Open the text file using a stream reader. using (StreamReader sr = new StreamReader("../../../Algorithms/tests/test.txt")) { String json = sr.ReadToEnd(); dynamic array = JsonConvert.DeserializeObject(json); // Console.WriteLine(array.attributes); Assert.True(true); var aa = array.attributes; for (int i = 0; i < array.attributes.Count - 1; i++) { table.addAttribute(array.attributes[i]); } table.addClassAttribute(array.attributes[array.attributes.Count - 1], "Name0", "Name1"); table.AddData(array.data); var p = new int[20]; for (int i = 0; i < p.Length; i++) { p[i] = i; } alg02.init(table); var rules = alg02.process(); for (int i = 0; i < rules.Count; i++) { output.WriteLine(rules[i].ToString()); } var rulesString = "a11 a33 ->c1;a12 a33 ->c2;a12 a31 ->c2;a11 a31 ->c1;a12 a32 ->c1;a11 a32 ->c2;a23 a34 ->c1;a21 a34 ->c2;a22 a34 a54 ->c2;a22 a34 a52 ->c1;a34 a42 ->c2;a11 a23 a32 a41 a54 ->c2;"; var currentRulesString = ""; for (int i = 0; i < rules.Count; i++) { currentRulesString += rules[i].ToStringOnlyTerm() + ";"; } Assert.Equal(rulesString, currentRulesString); } } catch (Exception e) { output.WriteLine(e.Message.ToString()); Assert.True(false); } }
static void performAlg02(FuzzyTable table, int indexForParam) { Console.WriteLine("performAlg02Exp: " + indexForParam); int size = 11; Double[] kriteriaArray = new Double[size]; var psi = new Dictionary <string, double>(); psi["no"] = 0.7; psi["yes"] = 0.7; for (int i = 0; i < size; i++) { var beta = 0.0 + 0.1 * i; var dataSize = 0; for (int j = 0; j < 40; j++) { Algorithm02 alg02; switch (indexForParam) { case 0: psi["no"] = beta; alg02 = new Algorithm02(0, psi); break; case 1: psi["yes"] = beta; alg02 = new Algorithm02(0, psi); break; default: alg02 = new Algorithm02(0, psi); break; } alg02.init(table); var validation02 = new TenCrossValidation(); var matrix02 = validation02.Validate(10, table, alg02); if (matrix02 != null) { var kriteria = (matrix02.Sensitivity() + matrix02.Specificity()) / 2; kriteriaArray[i] += kriteria; dataSize++; } } Console.WriteLine(indexForParam + " CURRENT beta: " + (beta) + " :" + kriteriaArray[i] / dataSize); } }