# coding=gbk import numpy as np from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt #准备数据 def guess(xi, xj, l1, l2): gamma = 0.1 return np.exp(-gamma*((xi - l1)**2+(xj - l2)**2)).tolist() x = np.arange(-4, 5, 1) y = np.array([i*2 for i in x]) c = ['r', 'r', 'r', 'b', 'b', 'b', 'r', 'r', 'r'] print(x) print(y) l1 = [i for i in [0, 0, 0]] l2 = [i for i in [0, 0, 0]] l3 = [i for i in [0, 0, 0]] l4 = [i for i in [0, 0, 0]] l5 = [i for i in [0, 0, 0]] l6 = [i for i in [0, 0, 0]] plt.scatter(x, y, marker='o', c=c) r1 = guess(x[:3], y[:3], l1, l2) r2 = guess(x[3:6], y[3:6], l3, l4) r3 = guess(x[6:], y[6:], l5, l6) for i in [r2, r3]: r1.extend(i) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.scatter3D(x, y, r1, c=c, s=45) plt.show()
高斯核函数就是选择landmark,然后旱地拔葱,升高维度
最新推荐文章于 2022-03-24 22:53:26 发布