import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.neighbors import KNeighborsClassifier

df = pd.read_csv('zoo.csv', header=0)

# Drop column 0 which has the class names
X = np.array(df.iloc[:, 1:17]) 	
y = np.array(df['class_type'])

# split the data into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.30)

knn = KNeighborsClassifier(n_neighbors=3)
knn.fit(X_train, y_train)
pred = knn.predict(X_test)

print('Index\tPredicted\tActual')
for i in range(len(pred)):
  if pred[i] != y_test[i]:
    print(i, '\t', pred[i], '\t\t', y_test[i], ' ****')
    
print (accuracy_score(y_test, pred))

