在运行python中,有sklearn,但是提示没有sklearn.cross_validation
时间: 2024-05-12 14:20:45 浏览: 148
在sklearn的最新版本中,sklearn.cross_validation已经被废弃了,推荐使用sklearn.model_selection代替。请尝试将您的代码中的cross_validation替换为model_selection,例如:
```python
from sklearn.model_selection import train_test_split
```
如果您的代码仍然无法找到模块,请尝试更新您的sklearn版本,使用以下命令:
```python
!pip install -U scikit-learn
```
或者
```python
!pip3 install -U scikit-learn
```
如果您使用的是anaconda或miniconda,请尝试使用以下命令更新:
```python
conda update scikit-learn
```
希望这可以帮助到您。
相关问题
from sklearn.cross_validation import train_test_split报错
在最新版本的scikit-learn中,`train_test_split`函数已经从`sklearn.cross_validation`模块移动到了`sklearn.model_selection`模块。因此,您需要将导入语句修改为:
```python
from sklearn.model_selection import train_test_split
```
如果您遇到了`ModuleNotFoundError`错误,请确保您已经正确安装了scikit-learn模块,并且使用的是最新版本。您可以使用以下命令来安装或更新scikit-learn:
```
pip install -U scikit-learn
```
如果您使用的是Python 3,则可能需要使用pip3命令:
```
pip3 install -U scikit-learn
```
请尝试修改导入语句并确保您的scikit-learn版本是最新的,这样就可以解决这个问题了。如果还有其他问题,请随时提问。
pychorm 中from sklearn.cross_validation import train_test_split报错
在较新版本的Scikit-learn中,`cross_validation`模块已被废弃。建议使用`model_selection`模块中的`train_test_split`函数。
您可以尝试使用以下代码替换:
```python
from sklearn.model_selection import train_test_split
```
如果您的Scikit-learn版本较老,可以考虑升级到最新版本。可以使用以下命令在终端中升级Scikit-learn:
```python
pip install -U scikit-learn
```
阅读全文
相关推荐

















