text_plain_output_1.png image_output_1.png
from sklearn.neighbors import KNeighborsClassifier

import pandas as pd

df = pd.read_csv('../input/house-votes.csv', na_values=['?'])
df.replace('^y$', value=1, regex=True, inplace=True)
df.replace('^n$', value=0, regex=True, inplace=True)
df.fillna(0, inplace=True)

df.to_csv('house-votes-edited.csv')

from sklearn.neighbors import KNeighborsClassifier
y = df['party'].values
X = df.drop('party', axis=1).values
knn = KNeighborsClassifier(n_neighbors=6)
knn.fit(X, y)