Category : distance

I have a pandas dataframe with the shape of: df.shape (1664599, 3935) that basically looks like: rws = ["user1","user2","user3","user4","user5","user6","user7","user8"] cols = ["prod1","prod2","prod3","prod4","prod5"] np.random.seed(0) df = pd.DataFrame(np.random.binomial(1, 0.3, size=(len(rws), len(cols))), columns=cols, index=rws) prod1 prod2 prod3 prod4 prod5 user1 0 1 0 0 0 user2 0 0 1 1 0 user3 1 0 0 1 0 user4 ..

Read more

In python, given one matrix of size 3*2 like A=[[x11,x12,x13],[x21,x22,x23]] and a column vector b=[mu1;mu2]. If I want to compute the Euclidean distance between each column of A and vector b. For example, for the first column, the distance ‘d1` is given by A=[[x11,x12,x13],[x21,x22,x23]] b=[[mu1],[mu2]] d1=(x11-mu1)^2+(x21-mu2)^2 #second column d2=(x12-mu1)^2+(x22-mu2)^2 # so on So the distance ..

Read more

I’m new and don’t understand things. I want to make a new list of distances between every coordinates I have, a list of the distances of point1-point2, point1-point3, point2-point3. so my code is: list_of_coords = [(5.55, 95.3175), (3.583333, 98.666667), (-0.95556, 100.36056)] list_of_distances = [geopy.distance.geodesic(combo).km for combo in combinations(list_of_coords,2)] anddd when I try to run it, ..

Read more

I’m studying the KNN algorithm to classify images using some material from a 2017 Stanford course. We’re given a dataset consisting of many images, later those sets are represented as 2D numpy arrays, and we’re supposed to write functions that calculate distances between those images. More specifically, given a 2D array of the test images ..

Read more