簡體   English   中英

計算2個數據幀之間的最小距離並估計一個數據幀中的缺失點位置

[英]calculate the minimum distance between 2 dataframe and estimate the missing points location in one dataframe

估計數據框:

指數 X
1 0.47 0.46
2 0.44 0.46
3 0.41 0.45
4 0.38 0.45
5 0.35 0.45
6 0.33 0.44
7 0.30 0.43
8 0.30 0.39

real_dataframe:

指數 X
1 0.46 0.463
4 0.40 0.453
5 0.37 0.455
6 0.34 0.450
7 0.32 0.448

目標:計算估計與真實之間的最小距離,並將距離與不匹配的估計數據點相加以指示真實數據幀中缺失的位置

缺失可能位於數據幀的中間,在這種情況下(2,3 和 8) real_missing 等於估計加上距離

指數 X
2 0.44 加 d 0.46加D
3 0.41 加 d 0.45加D
8 0.30 加 d 0.39加D
import math
mindistance = []
mindistance_x = []
mindistance_y = []
l_list = []
for x, y in zip(data_test.x_center,data_test.y_center):
    #x = data_test.x_center[0]
    #y = data_test.y_center[0]
    dist = []
    dist_x = []
    dist_y = []
    for w,z in zip(Estimated.x_center,Estimated.y_center):
        distance = math.sqrt((x - w)**2 + (y - z)**2)
        dist.append(distance)
        dist_x.append(x-w)
        dist_y.append(y-z)
    l = np.argmin(dist)
    l_list.append(l)
    mindistance.append(dist[l])
    mindistance_x.append(dist_x[l])
    mindistance_y.append(dist_y[l])

#average_min_distance = mean(mindistance)
#average_min_distance

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM