该报错一般是因为sklearn版本过低导致,先检查自己当前的sklearn的版本:
python -m pip show scikit-learn # to see which version and where scikit-learn is installed
python -m pip freeze # to see all packages installed in the active virtualenv
python -c "import sklearn; sklearn.show_versions()"
查询结果如下:
我之前使用0.24.2会报错,更新到1.3.2后报错解决。
下面是安装步骤:
pip install -U scikit-learn