image_output_1.png
from sklearn.neighbors import KNeighborsClassifier

import matplotlib.pyplot as plt

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

data = pd.read_csv('../input/classification/data.csv')
data.drop(['id', 'Unnamed: 32'], axis=1, inplace=True)

M = data[data['diagnosis'] == 'M']
B = data[data['diagnosis'] == 'B']

score_list = []
for each in range(1, 15):
    knn2 = KNeighborsClassifier(n_neighbors=each)
    knn2.fit(x_train, y_train)
    current_score = knn2.score(x_test, y_test)
    score_list.append(current_score)

knn3 = KNeighborsClassifier(n_neighbors=4)
knn3.fit(x_train, y_train)
current_score = knn3.score(x_test, y_test)
current_score