Question: Convert the following code from Matlab to Python: all_dist = pdist2(test_image_feats, train_image_feats, 'euclidean'); [sorted_dist, index] = sort(all_dist, 2); predicted_categories = train_labels(index(:, 1),:); test_image_feats and train_image_feats
Convert the following code from Matlab to Python:
all_dist = pdist2(test_image_feats, train_image_feats, 'euclidean');
[sorted_dist, index] = sort(all_dist, 2);
predicted_categories = train_labels(index(:, 1),:);
test_image_feats and train_image_feats are M x d matrices.
train_labels is an N x 1 cell array, where each entry is a string
I've converted the first line to:
D = sklearn_pairwise.pairwise_distances(test_image_feats, train_image_feats)
But I do not know how to do the last two lines.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
