When calling sklearn.model_selection tonight, an error was reported! After a bit of Baidu, I found that the comb position in scipy.misc has been moved to scipy.special, which is a bit small.
from sklearn.model_selection import train_test_split
D:\anaconda3\lib\site-packages\sklearn\model_selection\__init__.py in <module>() ----> 1 from ._split import BaseCrossValidator 2 from ._split import KFold 3 from ._split import GroupKFold 4 from ._split import StratifiedKFold 5 from ._split import TimeSeriesSplit D:\anaconda3\lib\site-packages\sklearn\model_selection\_split.py in <module>() 23 import numpy as np 24 ---> 25 from scipy.misc import comb 26 from ..utils import indexable, check_random_state, safe_indexing 27 from ..utils.validation import _num_samples, column_or_1d ImportError: cannot import name 'comb'
The solution is as follows:
In the python environment, it can be Anacanda or python, find the following two files, and open them for modification:
- File 1: lib\site-packages\sklearn\model_selection\_split.py, change from scipy.misc import comb in the file to from scipy.special import comb
- File 2: lib\site-packages\sklearn\metrics\cluster\supervised.py, change from scipy.misc import comb in the file to from scipy.special import comb
In the file, you can ctrl+f to enter keywords to quickly locate~~