Przeglądaj źródła

Merge branch 'master' of git.tflucke.name:tflucke/SSH-Master-Thesis

Thomas Flucke 6 lat temu
rodzic
commit
58173ef701

+ 9 - 0
ethan_data_processing_scripts/nearestneighbors.py

@@ -1,4 +1,5 @@
 from sklearn.neighbors import NearestNeighbors, KNeighborsClassifier
+from sklearn.ensemble import RandomForestClassifier
 import numpy as np
 import sys
 from Vector import *
@@ -23,6 +24,8 @@ def main():
     print(classifcations)
     print(newtest)
     kNearestNeighbors(newdata, classifcations, newtest)
+    # print("Random Forest:")
+    # randomForest(newdata, classifcations, newtest)
     # kNearestNeighbors([[1, 1, 0], [1, 0, 0], [0, 0, 0], [0, 5, 5]], ["three", 2, 3, "5"], [[1, 1, 0], [0, 5, 5]])
 
 
@@ -52,5 +55,11 @@ def nearestNeighbors(data: list, test_data: list):
     return indicies, dist
 
 
+def randomForest(data: list, classifications: list, test_data: list):
+    rfc = RandomForestClassifier(n_estimators=len(data))
+    rfc.fit(data, classifications)
+    print(rfc.predict(test_data))
+
+
 if __name__ == '__main__':
     main()