我正在尝试为逻辑回归中的边界分类绘制决策边界,但我不太明白应该怎么做。
这是我生成的一个数据集,我在其上使用 numpy 应用逻辑回归
import numpy as np
import matplotlib.pyplot as plt
# class 0:
# covariance matrix and mean
cov0 = np.array([[5,-4],[-4,4]])
mean0 = np.array([2.,3])
# number of data points
m0 = 1000
# class 1
# covariance matrix
cov1 = np.array([[5,-3],[-3,3]])
mean1 = np.array([1.,1])
# number of data points
m1 = 1000
# generate m gaussian distributed data points with
# mean and cov.
r0 = np.random.multivariate_normal(mean0, cov0, m0)
r1 = np.random.multivariate_normal(mean1, cov1, m1)
X = np.concatenate((r0,r1))
在应用逻辑回归后,我发现最好的 theta 是:
thetas = [1.2182441664666837, 1.3233825647558795, -0.6480886684022018]
我试图通过以下方式绘制决策边界:
yy = -(thetas[0] + thetas[1]*X)/thetas[1][2]
plt.plot(X,yy)
提前致谢