使用您选择的内核估计地面实况和预测数据集的密度。选择哪个内核取决于领域;盒内核或 RBF 可能是一个合理的选择。计算这些密度之间的差异。散度的概念再次取决于您,均方距离或 KL 散度可能会起作用。使用框核和均方实现:from scipy.signal import convolve2d# constants: don't forget to replace with your own valuesx_width, y_width = 10, 10kernel_width = 3gt_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 1gt_field[list(zip(*Set1))] = 1prediction_field[list(zip(*Set2))] = 1# using box kernel as the simplest onekernel = np.ones((kernel_width, kernel_width)) / kernel_width ** 2# apply kernel - now we have densitiesgt_field = convolve2d(gt_field, kernel)prediction_field = convolve2d(prediction_field, kernel)# calculate mean squared errormse = ((gt_field - prediction_field) ** 2).mean()我很确定有一种更有效的方法来实现它,但即使这样也应该像示例图片那样在几百个点上工作。