简单实现平面的点K均值分析,使用欧几里得距离,并用pylab展示。
复制代码 代码如下:import pylab as pl
#calc Euclid squiredef calc_e_squire(a, b): return (a[0]- b[0]) ** 2 + (a[1] – b[1]) **2
#init the 20 pointa = [2,4,3,6,7,8,2,3,5,6,12,10,15,16,11,10,19,17,16,13]b = [5,6,1,4,2,4,3,1,7,9,16,11,19,12,15,14,11,14,11,19]
#define two k_va
1