写了一个简单的调参脚本,作为程序入口:
from hyperopt import hp, STATUS_OK, Trials, fmin, tpe
import hyperopt
from sklearn.model_selection import cross_val_score
from sklearn import svm
from sklearn.datasets import load_iris
import numpy as np
iris=load_iris()
space = {
'C': hp.uniform('C', 0.001, 1000),
'shrinking': hp.choice('shrinking', [True, False]),
'kernel': hp.choice('kernel', [
{
'name': 'rbf',
'gamma': hp.choice('rbf_gamma', ['auto', hp.uniform('rbf_gamma_uniform',0.0001, 8)])
},
{
'name': 'linear',
},
{
'name': 'sigmoid',
'gamma': hp.choice('sigmoid_gamma', ['auto', hp.uniform('sigmoid_gamma_uniform',0.0001, 8)]),
'coef0': hp.uniform('sigmoid_coef0', 0, 10)
},
{
'name': 'poly',
'gamma': hp.choice('poly_gamma', ['auto', hp.uniform('poly_gamma_uniform',0.0001, 8)]),
'coef0': hp.uniform('poly_coef0', 0, 10),
'degree': hp.uniformint('poly_degree', 1,