优化决策树的超参数

问题描述 投票:0回答:1

我正在尝试使用sklearn网格搜索来找到决策树的最佳参数。

   parameter_space = {'max_features': ['auto', 'sqrt', 'log2'],
                     'ccp_alpha': [np.array(pd.Series(np.arange(0,1,0.001)))]}

   clf_tree = GridSearchCV(Dtree, parameter_space,cv=5)
   clf=clf_tree.fit(X,y)

I got the following error. I was wondering if you could help me to resolve this. I appreciate your time. 

    ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() 
python pandas scikit-learn decision-tree gridsearchcv
1个回答
0
投票

可能是吗?parameter_space = {'max_features':['auto','sqrt','log2'],'ccp_alpha':np.arange(0,1,0.001).tolist()}

© www.soinside.com 2019 - 2024. All rights reserved.