阿里天池机器学习课程学习笔记

​ 参加了阿里举办的机器学习基础课程,由于曾经有过一定的基础,在此简单记录一下一些不懂的问题。

调用sklearn库线性回归流程

from sklearn.linear_model import LogisticRegression
lr_clf = LogisticRegression()
lr_clf = lr_clf.fit(x_fearures, y_label) #进行拟合
lr_clf.predict_proba([x, y]) #进行预测

plt.contour() 绘制等高线

import matplotlab.plot as plt
plt.contour(x_grid, y_grid, z_proba, [0.5], linewidths=2., colors='blue')
# 其中 x_grid y_grid 为网格化数据,z_proba为其对应的高度,[0.5]为需要绘制等高线的位置。

决策边界可视化

plt.figure()
plt.scatter(x_fearures[:,0],x_fearures[:,1], c=y_label, s=50, cmap='viridis')
plt.title('Dataset')

nx, ny = 200, 100
x_min, x_max = plt.xlim()
y_min, y_max = plt.ylim()
x_grid, y_grid = np.meshgrid(np.linspace(x_min, x_max, nx),np.linspace(y_min, y_max, ny))

z_proba = lr_clf.predict_proba(np.c_[x_grid.ravel(), y_grid.ravel()])
z_proba = z_proba[:, 1].reshape(x_grid.shape)
plt.contour(x_grid, y_grid, z_proba, [0.5], linewidths=2., colors='blue')

plt.show()

利用sklearn创造混淆矩阵

from sklearn import metrics
## 查看混淆矩阵 (预测值和真实值的各类情况统计矩阵)
confusion_matrix_result = metrics.confusion_matrix(test_predict,y_test)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值