Python运行出现DeprecationWarning问题的解决方法

  

  小编写这篇文章的主要目的,就是给大家介绍一下关于日常生活中经常性出现的问题,那就是出现DeprecationWarning问题的解决方法,下面会给大家贴出相关的具体代码。

  Python运行出现DeprecationWarning

  今天运行py时出现下面的问题:

  DeprecationWarning:Using or importing the ABCs from'collections'instead of from'collections.abc'is deprecated since Python 3.3,and in 3.9 it will stop working

  是这个语句出现的问题:

from collections import Iterable

  好像是py版本更新以后包发生了变化,只需要改一下包名就行:

collections->collections.abc

  Python版本问题出现DeprecationWarning

sklearn.cross_validation.cross_val_score()

  例如:

from sklearn import cross_validation

  D:Anaconda3libsite-packagessklearncross_validation.py:41:DeprecationWarning:This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved.Also note that the interface of the new CV iterators are different from that of this module.This module will be removed in 0.20."This module will be removed in 0.20.",DeprecationWarning)

  改为

from sklearn.model_selection import cross_val_score

  综上所述,关于Python运行出现DeprecationWarning问题的解决方法就给大家介绍到这里了,希望可以为各位读者带来一定的帮助。

原创文章,作者:网友投稿,如若转载,请注明出处:https://www.cloudads.cn/archives/3997.html

发表评论

登录后才能评论