public Signal() { pca = new PCA(); knn = new KNN(); svm = new SVM(); svmscale = new SVMScale(); }
public Tuple <double[], double[], double[], double[]> getDistance(KNN obj, double[] test1, double[] test2) { double[] distancedown = obj.EuclideanDistance(downT7, downT8, test1, test2); double[] distanceup = obj.EuclideanDistance(upT7, upT8, test1, test2); double[] distanceleft = obj.EuclideanDistance(leftT7, leftT8, test1, test2); double[] distanceright = obj.EuclideanDistance(rightT7, rightT8, test1, test2); return(new Tuple <double[], double[], double[], double[]>(distancedown, distanceup, distanceleft, distanceright)); }
public void buildCorpus(string subName = "karrar") { KNN P = new KNN(); string channelName1 = "IED_T8"; downT8 = P.readCSV(subName + "Down", channelName1); upT8 = P.readCSV(subName + "Up", channelName1); rightT8 = P.readCSV(subName + "Right", channelName1); leftT8 = P.readCSV(subName + "Left", channelName1); string channelName2 = "IED_T7"; downT7 = P.readCSV(subName + "Down", channelName2); upT7 = P.readCSV(subName + "Up", channelName2); rightT7 = P.readCSV(subName + "Right", channelName2); leftT7 = P.readCSV(subName + "Left", channelName2); }
public double calculateKNNAccuracy() { if (fileExistance) { KNN knn = new KNN(); if (rightTestData != null) { knn.setRight(rightTrainData); } if (leftTestData != null) { knn.setLeft(leftTrainData); } if (upTestData != null) { knn.setUp(upTrainData); } if (downTestData != null) { knn.setDown(downTrainData); } if (neutralTestData != null) { knn.setNeutral(neutralTrainData); } double tp = 0, fp = 0; if (rightTestData != null) { for (int i = 0; i < rightTestData.Length; i++) { if (knn.knnClassifier(rightTestData[i]) == "Right") { tp++; } else { fp++; } } } if (leftTestData != null) { for (int i = 0; i < leftTestData.Length; i++) { if (knn.knnClassifier(leftTestData[i]) == "Left") { tp++; } else { fp++; } } } if (upTestData != null) { for (int i = 0; i < upTestData.Length; i++) { if (knn.knnClassifier(upTestData[i]) == "Up") { tp++; } else { fp++; } } } if (downTestData != null) { for (int i = 0; i < downTestData.Length; i++) { if (knn.knnClassifier(downTestData[i]) == "Down") { tp++; } else { fp++; } } } if (neutralTestData != null) { for (int i = 0; i < neutralTestData.Length; i++) { if (knn.knnClassifier(neutralTestData[i]) == "Neutral") { tp++; } else { fp++; } } } double accuracy = (tp / (tp + fp)) * 100; return(accuracy); } else { return(0); } }