Skip to content

Commit

Permalink
Update knn.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Manos Gionanidis authored Jan 31, 2019
1 parent a1f9804 commit e6c5b67
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions classifiers/knn.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ def knn_ROC(data):
for n in range(5,20):
n_neighbours.append(n)
#KNN for variable number of neighbors , check the rates and plot them according to the number of neighbors
knn = KNeighborsClassifier(n_neighbors=n).fit(X,Y)
x_train, x_test, y_train, y_test = train_test_split(X,Y, test_size=0.20)


knn = KNeighborsClassifier(n_neighbors=n).fit(x_train,y_train)
for l in range(len(Y)):
if Y[l]==knn.predict(X)[l]:
if Y[l]==knn.predict(x_test)[l]:
#every time the prediction is right
accuracy+=1
#calcuate the rate %
Expand Down

0 comments on commit e6c5b67

Please sign in to comment.