1
0

2 کامیت‌ها 35b818b404 ... 2ea2643164

نویسنده SHA1 پیام تاریخ
  Ethan Goldfarb 2ea2643164 Merge branch 'master' of https://git.tflucke.name/tflucke/SSH-Master-Thesis 6 سال پیش
  Ethan Goldfarb 68ee8904d3 added a random forest classifier, will work into command soon: 6 سال پیش
1فایلهای تغییر یافته به همراه9 افزوده شده و 0 حذف شده
  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.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()