简体   繁体   中英

Optimize hyper-parameters of a decision tree

I am trying to use to sklearn grid search to find the optimal parameters for the decision tree.

Dtree= DecisionTreeRegressor()
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() 

也许这个?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM