Rhettp
Rhettp

Reputation: 11

N objective function parameters in hyperopt

I'm trying to use hyperopt to optimize the hyperparameters of an SVC model.

This is the definition of space:

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'])
}

This is my objective function:

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}

Now, my doubts are:

  1. Should the parameter name of function my_space, that is ol, be the same as the space name gty?

  2. How do I use the **, in order to avoid writing

    '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'])
    

in the objective function myfunc, again? Is what I've written, ol, correct?

Upvotes: 1

Views: 245

Answers (0)

Related Questions