2 Achegas 35b818b404 ... 2ea2643164

Autor SHA1 Mensaxe Data
  Ethan Goldfarb 2ea2643164 Merge branch 'master' of https://git.tflucke.name/tflucke/SSH-Master-Thesis %!s(int64=6) %!d(string=hai) anos
  Ethan Goldfarb 68ee8904d3 added a random forest classifier, will work into command soon: %!s(int64=6) %!d(string=hai) anos
Modificáronse 1 ficheiros con 9 adicións e 0 borrados
  1. 9 0
      ethan_data_processing_scripts/nearestneighbors.py

+ 9 - 0
ethan_data_processing_scripts/nearestneighbors.py

@@ -1,4 +1,5 @@
 from sklearn.neighbors import NearestNeighbors, KNeighborsClassifier
 from sklearn.neighbors import NearestNeighbors, KNeighborsClassifier
+from sklearn.ensemble import RandomForestClassifier
 import numpy as np
 import numpy as np
 import sys
 import sys
 from Vector import *
 from Vector import *
@@ -23,6 +24,8 @@ def main():
     print(classifcations)
     print(classifcations)
     print(newtest)
     print(newtest)
     kNearestNeighbors(newdata, classifcations, 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]])
     # 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
     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__':
 if __name__ == '__main__':
     main()
     main()