如何对 SVC 进行超参数调整?
How to perform hyper-paramter tunning for SVC?
我正在尝试对我的模型执行超参数调整,但此错误一直显示
error : Invalid parameter svc_c for estimator SVC(). Check the list of available parameters with `estimator.get_params().keys()
我正在使用以下代码:
param_grid = {'svc_c': [5, 10, 100],
'svc_gamma': [1,0.1,0.01,0.001],
'svc_dgree': [1,2,3,4,5,6],
'svc_kernel': ['rbf']}
grid = GridSearchCV(SVC(),param_grid,refit=True,verbose=3)
grid.fit(x_train_poly,y_train)
您需要为词典 param_grid
使用正确的键。
kernel
、C
、gamma
、degree
和...(参见 doc)
试试这个:
param_grid = {'kernel': ('linear', 'rbf','poly') ,
'C':[5, 10, 100],
'gamma': [1,0.1,0.01,0.001],
'degree' : [1,2,3,4,5,6]}
grid = GridSearchCV(SVC() , param_grid , refit=True , verbose=3)
grid.fit(x_train_poly,y_train)
如错误消息所述,您正在为每个超参数设置无效的参数名称。在此 中,展示了一种显示给定估计器的可用超参数列表的方法。然后,我建议您将代码更改为:
param_grid = {'C': [5, 10, 100],
'gamma': [1,0.1,0.01,0.001],
'degree': [1,2,3,4,5,6],
'kernel': ['rbf']}
请检查那些超参数是否真的包含在列表中
estimator.get_params().keys()
returns.
我正在尝试对我的模型执行超参数调整,但此错误一直显示
error : Invalid parameter svc_c for estimator SVC(). Check the list of available parameters with `estimator.get_params().keys()
我正在使用以下代码:
param_grid = {'svc_c': [5, 10, 100],
'svc_gamma': [1,0.1,0.01,0.001],
'svc_dgree': [1,2,3,4,5,6],
'svc_kernel': ['rbf']}
grid = GridSearchCV(SVC(),param_grid,refit=True,verbose=3)
grid.fit(x_train_poly,y_train)
您需要为词典 param_grid
使用正确的键。
kernel
、C
、gamma
、degree
和...(参见 doc)
试试这个:
param_grid = {'kernel': ('linear', 'rbf','poly') ,
'C':[5, 10, 100],
'gamma': [1,0.1,0.01,0.001],
'degree' : [1,2,3,4,5,6]}
grid = GridSearchCV(SVC() , param_grid , refit=True , verbose=3)
grid.fit(x_train_poly,y_train)
如错误消息所述,您正在为每个超参数设置无效的参数名称。在此
param_grid = {'C': [5, 10, 100],
'gamma': [1,0.1,0.01,0.001],
'degree': [1,2,3,4,5,6],
'kernel': ['rbf']}
请检查那些超参数是否真的包含在列表中
estimator.get_params().keys()
returns.