CS231n
CS231n copied to clipboard
Incorrect Cross-validation for knn.
In knn.ipynb file, you have:
y_cross_validation_pred = classifier_k.predict_labels(X_train_folds[n], k)
This is incorrect because predict_labels
takes in a distance matrix but you pass in a raw test matrix. So, you need to have an additional step as:
dists = classifier.compute_distances_no_loops(X_train_folds[n])
y_cross_validation_pred = classifier_k.predict_labels(dists, k)
Or you can use predict
function in k_nearest_neighbor
which technically does the same thing:
y_cross_validation_pred = classifier_k.predict(dists, k)
@nghiattran Yes but if you use the predict function then you would pass in the raw test matrix, not the distance matrix