我正在運行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 –
啊,很好,這是一個簡單的解決方案!謝謝 :) –