1

我正在尝试使用 hyperopt 来优化 SVC 模型的超参数。

这是空间的定义:

gty= {
'C': hp.loguniform('C_ro',-4*np.log(10),5*np.log(10)),
'gamma': hp.loguniform('gamma_ro',2.0,4.0),
'tol': hp.uniform('tol-ro',0.0001,0.001),
'kernel': hp.choice('Kerenel_ro',['linear', 'rbf', 'sigmoid'])
}

这是我的目标函数:

def myfunc(ol):
    vc = SVC(max_iter=1900,
           **ol
            )
    
    vc.fit(io,y_train.values.ravel())
    
    pred = vc.predict(io1)
    
    gh = accuracy_score(y_test,pred)
    
    return {'loss': -gh, 'status': STATUS_OK}

现在,我的疑问是:

  1. 函数my_space的参数名,也就是ol空间名应该和空间名一样gty吗?

  2. 我如何使用**, 以避免写

    'C': hp.loguniform('C_ro',-4*np.log(10),5*np.log(10)),
        'gamma': hp.loguniform('gamma_ro',2.0,4.0),
        'tol': hp.uniform('tol-ro',0.0001,0.001),
        'kernel': hp.choice('Kerenel_ro',['linear', 'rbf', 'sigmoid'])
    

在目标函数myfunc中,再次?我写的,对ol吗?

4

0 回答 0