代码语言:javascript复制
>>> from sklearn.linear_model import RandomizedLogisticRegression
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'RandomizedLogisticRegression'
但作为回报,我得到以下错误:
ImportError:无法导入名称“ RandomizedLogisticRegression”
原因
linear_model.RandomizedLogisticRegression
和 linear_model.RandomizedLasso
在scikit-learn 0.19中弃用,并在0.21中移除。
解决方法1
代码语言:javascript复制pip install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com scikit-learn==0.19.2
解决方法2
代码语言:javascript复制pip install https://github.com/scikit-learn-contrib/stability-selection.zip
from stability_selection.randomized_lasso import RandomizedLogisticRegression as RLR
参考:https://www.cnpython.com/qa/400503 https://blog.csdn.net/weixin_44566432/article/details/109808289 https://blog.csdn.net/michaelguangg/article/details/100036650 https://ask.csdn.net/questions/7466312