public void parseFile() { string[] lines = System.IO.File.ReadAllLines(@"E:\College\Pattern Recognition\Labs\Lab5\Task (4)\Iris Data.txt"); for (int i = 1; i < lines.Length; i++) { string[] tmp = lines[i].Split(','); IRIS_flower obj = new IRIS_flower(); for (int j = 0; j < 4; j++) { obj.features[j] = double.Parse(tmp[j]); } if (tmp[4] == "Iris-setosa") { class1_Dataset.Add(obj); } else if (tmp[4] == "Iris-versicolor") { class2_Dataset.Add(obj); } else if (tmp[4] == "Iris-virginica") { class3_Dataset.Add(obj); } } }
public bool parzenWindow(IRIS_flower sample, IRIS_flower training) { double distance = 0; for (int i = 0; i < 4; i++) { distance += Math.Pow(sample.features[i] - training.features[i], 2); } distance = Math.Sqrt(distance) / windowSize; return(distance <= 0.5); }