1 回答

TA貢獻1864條經驗 獲得超6個贊
使用您選擇的內核估計地面實況和預測數據集的密度。選擇哪個內核取決于領域;盒內核或 RBF 可能是一個合理的選擇。
計算這些密度之間的差異。散度的概念再次取決于您,均方距離或 KL 散度可能會起作用。
使用框核和均方實現:
from scipy.signal import convolve2d
# constants: don't forget to replace with your own values
x_width, y_width = 10, 10
kernel_width = 3
gt_field = np.zeros((x_width, y_width))
prediction_field = gt_field.copy()
# split Set1 into two lists of x and y coordinates
# then set these points to 1
gt_field[list(zip(*Set1))] = 1
prediction_field[list(zip(*Set2))] = 1
# using box kernel as the simplest one
kernel = np.ones((kernel_width, kernel_width)) / kernel_width ** 2
# apply kernel - now we have densities
gt_field = convolve2d(gt_field, kernel)
prediction_field = convolve2d(prediction_field, kernel)
# calculate mean squared error
mse = ((gt_field - prediction_field) ** 2).mean()
我很確定有一種更有效的方法來實現它,但即使這樣也應該像示例圖片那樣在幾百個點上工作。
添加回答
舉報