从“sklearn”Python库中得到很多错误[关闭]

Posted

技术标签:

【中文标题】从“sklearn”Python库中得到很多错误[关闭]【英文标题】:Got many error from "sklearn" Python library [closed] 【发布时间】:2022-01-12 08:09:25 【问题描述】:

我在jupyter中运行简单代码:

from sklearn.datasets import load_iris
iris = load_iris()

我没有使用 numpy 库,但我得到了这个:

g:\program files\python37\lib\site-packages\sklearn\feature_extraction\image.py:167: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  dtype=np.int):
g:\program files\python37\lib\site-packages\sklearn\datasets\base.py:240: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  target = np.empty((n_samples,), dtype=np.int)
g:\program files\python37\lib\site-packages\sklearn\datasets\base.py:244: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  target[i] = np.asarray(ir[-1], dtype=np.int)

【问题讨论】:

这不是错误,只是对一些已弃用的sklearn 功能的警告 您应该执行pip install -U scikit-learn numpy,因为您似乎使用的是旧软件包版本。 【参考方案1】:

您的库似乎已过时,因此出现此弃用警告。

我建议您使用以下命令更新numpyscikit-learn

pip install -U scikit-learn numpy

【讨论】:

以上是关于从“sklearn”Python库中得到很多错误[关闭]的主要内容,如果未能解决你的问题,请参考以下文章

python-sklearn中出现“ValueError:预期的二维数组,得到一维数组”错误[重复]

Python SVM 设置具有序列错误的数组元素

在“Keras”分类中使用“sklearn”库中计算类权重函数问题(Python 3.8,仅在 VS 代码中)

在 sklearn 或任何 python 库中确定对非线性 SVM 回归贡献最大的特征

Python 导入错误:无法从“sklearn.externals”导入名称“六”

can't install specific old version of sklearn to解决pyadio分析库中不兼容的“SVC属性错误”