Académique Documents
Professionnel Documents
Culture Documents
df.replace({'n':0,'y':1,'?':0},inplace=True)
In [5]: # Create arrays for the features and the response variable
y = df['party'].values
X = df.drop('party', axis=1).values
In [7]: X_new
Out[7]:
0 1 2 3 4 5 6 7
file:///D:/komal/SIMPLILEARN/MY%20COURSES/IN%20PROGRESS/My%20Codes_ML_DS/codes%20in%20pdf/komal_knn1_sayan_houseVotes.html 1/2
9/7/2018 komal_knn1_sayan_houseVotes
# Predict and print the label for the new data point X_new
new_prediction = knn.predict(X_new)
print("Prediction: {}".format(new_prediction))
Prediction: ['democrat']
file:///D:/komal/SIMPLILEARN/MY%20COURSES/IN%20PROGRESS/My%20Codes_ML_DS/codes%20in%20pdf/komal_knn1_sayan_houseVotes.html 2/2