private void button3_Click(object sender, EventArgs e) { Glass newGlass = new Glass(-1, (double)riNum.Value, (double)naNum.Value, (double)mgNum.Value, (double)alNum.Value, (double)siNum.Value, (double)kNum.Value, (double)caNum.Value, (double)baNum.Value, (double)feNum.Value, -1); var neuralOutput = network.GetOutputs(newGlass); output(("[BACK PROPOGATION] Siūloma tipas: "******"[K-Nearest-Neighbors] Siūloma tipas: "******"[Bayes] Siūloma tipas: " + bayes.test(newGlass))); }
private void bajes_start_Click(object sender, EventArgs e) { double averageAccurasy = 0; List <Glass> glasses = new List <Glass>(); if (radioButton1.Checked) { glasses = dataList; } else { glasses = clearDistantValuesFromList(dataList); } int testingFileCount = glasses.Count / NUMBER_OF_SEGMENTS; for (int segment = 0; segment < NUMBER_OF_SEGMENTS; segment++) { richTextBox1.AppendText(String.Format("Crosscheck segment {0} \n ", segment + 1)); int correctGuesses = 0; int guessCounter = 0; int falseGuesses = 0; int testingDataFromIndex = segment * testingFileCount; int testingDataToIndex = (segment + 1) * testingFileCount; var trainingData = new List <Glass>(); var testingData = new List <Glass>(); for (int i = 0; i < glasses.Count; i++) { if (i >= testingDataFromIndex && i <= testingDataToIndex) { testingData.Add(glasses[i]); } else { trainingData.Add(glasses[i]); } } BayesClassifier bayes = new BayesClassifier(trainingData.Count); bayes.trainClassifier(trainingData); foreach (Glass glass in testingData) { int guess = bayes.test(glass); if (guess == glass.group_type) { correctGuesses++; } else { falseGuesses++; } guessCounter++; } var totalGlasses = glasses.Count; var totalTrain = trainingData.Count; var totalTest = testingData.Count; double trainProc = Math.Round(((double)totalTrain / totalGlasses) * 100, 2); double testProc = Math.Round(((double)totalTest / totalGlasses) * 100, 2); double accuracy = Math.Round(((double)correctGuesses / guessCounter) * 100, 2); averageAccurasy += accuracy; richTextBox1.AppendText(string.Format("Total: {0, 3}; Training: {1, 3}({2, 4}%); Testing: {3, 3}({4, 4}%)\n", totalGlasses, totalTrain, trainProc, totalTest, testProc)); richTextBox1.AppendText(string.Format("Correct guesses: {0, 3} ; Total guesses: {1, 3} ; Accuracy: {2, 4}%\n", correctGuesses, guessCounter, accuracy)); } richTextBox1.AppendText(string.Format("Average accurasy of all segments - {0}%\n", averageAccurasy / NUMBER_OF_SEGMENTS)); }