逻辑回归(LogisticrGression)

逻辑回归是即可用于分类有可用于回归,即自变量既可以是连续的又可以是离散的。


# import some data to play with
iris = datasets.load_iris()
X = iris.data[:, :2]  # we only take the first two features.第一维度所有都要,第二维度只要前两个
Y = iris.target


h = .02  # step size in the mesh


logreg = linear_model.LogisticRegression(C=1e5)


# we create an instance of Neighbours Classifier and fit the data.
logreg.fit(X, Y)


# Plot the decision boundary(边界). For that, we will assign a color to each
# point in the mesh [x_min, x_max]x[y_min, y_max].找出X,Y的最值
x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5
y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5


#绘出每个点的xy坐标
xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))#meshgrid 坐标格点
#print(xx,yy)
Z = logreg.predict(np.c_[xx.ravel(), yy.ravel()])


# Put the result into a color plot
Z = Z.reshape(xx.shape)
plt.figure(1, figsize
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值