网格搜索后如何为 SVM 回归选择超参数?

机器算法验证 回归 机器学习 支持向量机 scikit-学习
2022-03-30 13:06:52

个点的小数据集,每个点有四个特征。我计划拟合 SVM 回归,因为值给了我定义容差值的可能性,这在其他回归技术中是不可能的。150ε

的不同值值运行了交叉验证的网格搜索对于的不同组合,我收到相似的分数(如网格和结果中所示)。γCεεγC

问题:如何定义改进超参数选择和为我的数据集建立合理模型的标准?

结果:

**Epsilon = 0.06**
The best parameters are {'C': 48.939009184774889, 'gamma': 0.03562247890262444} with a score of 0.64 

**Epsilon = 0.09**
The best parameters are {'C': 48.939009184774889, 'gamma': 0.03562247890262444} with a score of 0.64 

**Epsilon = 0.11**
The best parameters are {'C': 48.939009184774889, 'gamma': 0.03562247890262444} with a score of 0.66 

**Epsilon = 0.14**
The best parameters are {'C': 48.939009184774889, 'gamma': 0.03562247890262444} with a score of 0.67 

**Epsilon = 0.17**
The best parameters are {'C': 48.939009184774889, 'gamma': 0.03562247890262444} with a score of 0.66 

**Epsilon = 0.19**
The best parameters are {'C': 48.939009184774889, 'gamma': 0.03562247890262444} with a score of 0.65 

**Epsilon = 0.22**
The best parameters are {'C': 48.939009184774889, 'gamma': 0.03562247890262444} with a score of 0.64 

**Epsilon = 0.25**
The best parameters are {'C': 14873.521072935118, 'gamma': 0.00072789538439831537} with a score of 0.65 

**Epsilon = 0.27**
The best parameters are {'C': 621.0169418915616, 'gamma': 0.0038566204211634724} with a score of 0.65 

**Epsilon = 0.30**
The best parameters are {'C': 4175.3189365604003, 'gamma': 0.0012689610031679235} with a score of 0.66

网格搜索结果

网格搜索结果

1个回答

虽然我还没有完全理解这个问题,但我正在根据我对这个问题的理解来回答。

您是否尝试将 Epsilon 包含在param_gridGrid_searchCV 字典中。

我看到您只使用Candgamma作为param_griddict 中的参数。

然后我认为系统本身会为您选择最好的 Epsilon。

例子:

from sklearn.svm import SVR
import numpy as np
n_samples, n_features = 10, 5
np.random.seed(0)
y = np.random.randn(n_samples)
X = np.random.randn(n_samples, n_features)
parameters = {'kernel': ('linear', 'rbf','poly'), 'C':[1.5, 10],'gamma': [1e-7, 1e-4],'epsilon':[0.1,0.2,0.5,0.3]}
svr = svm.SVR()
clf = grid_search.GridSearchCV(svr, parameters)
clf.fit(X,y)
clf.best_params_

输出:{'C': 1.5, 'epsilon': 0.1, 'gamma': 1e-07, 'kernel': 'poly'}