Python 使用Hyperopt的贝叶斯优化中的错误

Python 使用Hyperopt的贝叶斯优化中的错误,python,optimization,scikit-learn,valueerror,hyperopt,Python,Optimization,Scikit Learn,Valueerror,Hyperopt,当我使用Hyperopt进行贝叶斯优化时,以下代码中出现值错误: from hpsklearn import HyperoptEstimator, any_classifier from sklearn.datasets import fetch_openml from hyperopt import tpe import numpy as np # Download the data and split into training and test sets digits = fetch_

当我使用Hyperopt进行贝叶斯优化时,以下代码中出现值错误:

from hpsklearn import HyperoptEstimator, any_classifier
from sklearn.datasets import fetch_openml
from hyperopt import tpe
import numpy as np

# Download the data and split into training and test sets

digits = fetch_openml('mnist_784')

X = digits.data
y = digits.target

test_size = int( 0.2 * len( y ) )
np.random.seed( 100 )
indices = np.random.permutation(len(X))
X_train = X[ indices[:-test_size]]
y_train = y[ indices[:-test_size]]
X_test = X[ indices[-test_size:]]
y_test = y[ indices[-test_size:]]

estim = HyperoptEstimator( classifier=any_classifier('clf'),  
                            algo=tpe.suggest, trial_timeout=300)

estim.fit( X_train, y_train )

print( estim.score( X_test, y_test ) )

print( estim.best_model() )
错误如下:

100%|██████████| 1/1 [05:00<00:00, 300.17s/it, best loss: ?]
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-4-0c8c24abd852> in <module>()
     22                             algo=tpe.suggest, trial_timeout=300)
     23 
---> 24 estim.fit( X_train, y_train )
     25 
     26 print( estim.score( X_test, y_test ) )

9 frames
<__array_function__ internals> in argmin(*args, **kwargs)

/usr/local/lib/python3.6/dist-packages/numpy/core/fromnumeric.py in _wrapit(obj, method, *args, **kwds)
     45     except AttributeError:
     46         wrap = None
---> 47     result = getattr(asarray(obj), method)(*args, **kwds)
     48     if wrap:
     49         if not isinstance(result, mu.ndarray):

ValueError: attempt to get argmin of an empty sequence
100%|██████████| 1/1[05:00 24预计适合(X_列车,y_列车)
25
26打印(估计分数(X_检验、y_检验))
9帧
在argmin(*args,**kwargs)中
/wrapit中的usr/local/lib/python3.6/dist-packages/numpy/core/fromneric.py(obj,method,*args,**kwds)
45除属性错误外:
46=无
--->47结果=getattr(asarray(obj),方法)(*args,**kwds)
48如果包裹:
49如果不存在(结果,最小值):
ValueError:尝试获取空序列的argmin
有人能帮我解决这个错误吗?我试了很多次,但这个错误仍然存在