In test data section, the accuracy is computed as integer ... Changing to float is better. acc = np.sum(y_pred == y_test) / np.size(y_pred) in acc = np.float(np.sum(y_pred == y_test)) / np.float(np.size(y_pred))