Skip to content
Snippets Groups Projects
Commit 7460daf4 authored by Dubray Chloe's avatar Dubray Chloe
Browse files

Upload New File

parent e4e553b0
No related branches found
No related tags found
No related merge requests found
knn.py 0 → 100644
import numpy as np
import pickle
import os
def distance_matrix (M1, M2) :
sum_squares_1 = np.sum(M1**2, axis = 1, keepdims = True)
sum_squares_2 = np.sum(M2**2, axis = 1, keepdims = True)
dot_product = np.dot(M1, M2.T)
dists = np.sqrt(sum_squares_1 - 2*dot_product + sum_squares_2.T)
return dists
split_dataset (data, labels, split)
def knn_predict (dists, labels_train, k) :
train_set
test_set
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment