逻辑回归代码问题

weixin_42745366 2019-06-25 05:31:00
最近在学习《Python数据分析与挖掘实战》的时候,在第5章的逻辑回归代码,

data = pd.read_excel('c:/Users/EDZ/Desktop/Python/chapter5/demo/data/bankloan.xls')
x = data.iloc[:,:8].values #取前8列作为x矩阵
y = data.iloc[:,8].values #取第9列作为y矩阵

from sklearn.linear_model import LogisticRegression as LR
from sklearn.linear_model import RandomizedLogisticRegression as RLR
rlr = RLR() #建立随机逻辑回归模型,筛选变量
rlr.fit(x,y) #训练模型
rlr.get_support() #获取特征筛选结果,也可以通过.scores_方法获取各个特征的分数
print('通过随机逻辑回归模型筛选特征结束。')
data1 = data.drop('违约',1)
print('有效特征值为:%s' % ','.join(data1.columns[rlr.get_support()]))
x = data1[data1.columns[rlr.get_support()]].values #筛选好特征值

lr = LR() #建立逻辑回归模型
lr.fit(x,y) #用筛选后的特征数据来训练模型
print('逻辑回归模型训练结束。')
print('模型的平均正确率为:%s' % lr.score(x,y)) #给出模型的平均正确率


出现了FutureWaring,内容为:
Class RandomizedLogisticRegression is deprecated; The class RandomizedLogisticRegression is deprecated in 0.19 and will be removed in 0.21.
warnings.warn(msg, category=DeprecationWarning)
C:\Users\EDZ\Anaconda3\lib\site-packages\sklearn\utils\deprecation.py:58: DeprecationWarning: Class Memory is deprecated; deprecated in version 0.20.1 to be removed in version 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib.
warnings.warn(msg, category=DeprecationWarning)

请问需要如何修改呢?还请大神们指教,小弟初入数据分析
...全文
197 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
罗卜基斯 2019-07-01
  • 打赏
  • 举报
回复
这只是个提示,显示RandomizedLogisticRegression提示, 可以用numpy.resample抽样 + LogisticRegression来做
qq_38651100 2019-07-01
  • 打赏
  • 举报
回复
朋友,那个对应的数据能不能分享下呢

37,719

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧