python划分边界_二元分类决策边界线的绘制

我目前为决策边界训练了一个逻辑模型,如下所示:

使用我在网上得到的以下代码:x_min, x_max = xbatch[:, 0].min() - .5, xbatch[:, 0].max() + .5

y_min, y_max = xbatch[:, 1].min() - .5, xbatch[:, 1].max() + .5

h = 0.05

# Generate a grid of points with distance h between them

xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))

X = np.vstack( ( xx.reshape(1, np.product(xx.shape)), yy.reshape(1, np.product(yy.shape)) ) ).T

# Predict the function value for the whole grid

z1 = np.dot(X, w1_pred)+b1_pred

h1 = 1 / (1 + np.exp(-z1))

z2 = np.dot(h1, w2_pred)+b2_pred

y_hat = 1 / (1 + np.exp(-z2))

pred = np.round(y_hat)

Z = pred.reshape(xx.shape)

# Plot the contour and training examples

plt.contourf(xx, yy, Z)

plt.scatter(xbatch[:, 0], xbatch[:, 1], c=ybatch, s=40, edgecolors="grey", alpha=0.9)

我的问题是:

有没有办法在没有网格或轮廓的情况下绘制决策线?在

我只想在图上画出波的sigmoid函数。没有颜色或轮廓,所以看起来像这样:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值