高斯核函数就是选择landmark,然后旱地拔葱,升高维度

50 篇文章 4 订阅
15 篇文章 0 订阅
# 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()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值