我正在运行GridSearchCV
,其中OneVsRestClasssifer
使用SVC
作为估算值。这是我Pipeline
和GridSearchCV
参数方面:GridSearchCV是用rbf内核和不同程度计算SVC吗?
pipeline = Pipeline([
('clf', OneVsRestClassifier(SVC(verbose=True), n_jobs=1)),
])
parameters = {
"clf__estimator__C": [0.1, 1],
"clf__estimator__kernel": ['poly', 'rbf'],
"clf__estimator__degree": [2, 3],
}
grid_search_tune = GridSearchCV(pipeline, parameters, cv=2, n_jobs=8, verbose=10)
grid_search_tune.fit(train_x, train_y)
根据SVC的文档degree
参数仅用于由poly
内核:
http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html
度:INT,可选(默认= 3)
多项式内核的程度 函数('poly')。被所有其他内核忽略。
,但是当我看到我的GridSearchCV
的输出似乎它的计算与一个rbf
内核的不同值degree
参数每个SVC
配置不同的运行。
[CV] clf__estimator__kernel=poly, clf__estimator__C=0.1, clf__estimator__degree=2
[CV] clf__estimator__kernel=poly, clf__estimator__C=0.1, clf__estimator__degree=2
[CV] clf__estimator__kernel=rbf, clf__estimator__C=0.1, clf__estimator__degree=2
[CV] clf__estimator__kernel=rbf, clf__estimator__C=0.1, clf__estimator__degree=2
[CV] clf__estimator__kernel=poly, clf__estimator__C=0.1, clf__estimator__degree=3
[CV] clf__estimator__kernel=poly, clf__estimator__C=0.1, clf__estimator__degree=3
[CV] clf__estimator__kernel=rbf, clf__estimator__C=0.1, clf__estimator__degree=3
[CV] clf__estimator__kernel=rbf, clf__estimator__C=0.1, clf__estimator__degree=3
当内核设置为rbf
时,不应该忽略度数的所有值吗?
感谢您的回答,我必须检查分数,但我怀疑对于每个不同的度数值,运行一个SVC(kernel ='rbf')正在计算,如果是真的,这是浪费时间,因为所有的分数应该是相同的。 GridSearchCV应该是“聪明的”,足以放弃这些分数,我会写关于它的sklearn邮件列表。 –
@DavidBatista是的。相同的运行将针对不同的度数值进行计算。确定邮件列表。我们可以将字典更改为只有兼容组合的字典列表。像'tuned_parameters'在:http://scikit-learn.org/stable/auto_examples/model_selection/grid_search_digits.html#sphx-glr-auto-examples-model-selection-grid-search-digits-py –
啊,很好,这是一个简单的解决方案!谢谢 :) –