cannot import name 'cross_validation' from 'sklearn'
时间: 2023-10-09 15:15:19 浏览: 147
The error message suggests that there is an issue with importing the `cross_validation` module from the `sklearn` package.
Starting from `sklearn` version 0.22, the `cross_validation` module has been moved to `model_selection`. Therefore, you might want to check if you are using an outdated version of `sklearn`.
To fix this error, you can replace `cross_validation` with `model_selection` in your import statement. For example, instead of:
```
from sklearn.cross_validation import train_test_split
```
You can use:
```
from sklearn.model_selection import train_test_split
```
If you are using an older version of `sklearn` and cannot update it, you can try installing an older version of the package that still has the `cross_validation` module. You can check the release notes of each `sklearn` version to see if it has the `cross_validation` module or not.
阅读全文