【发布时间】:2023-10-26 03:35:01
【问题描述】:
我正在运行 GridSearchCV 和 OneVsRestClasssifer,使用 SVC 作为估算器。这是我的Pipeline 和GridSearchCV 参数的方面:
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
degree:int,可选(默认=3)
多项式核的度数 函数('poly')。被所有其他内核忽略。
但是当我看到GridSearchCV 的输出时,它似乎正在为每个SVC 配置计算不同的运行,其中rbf 内核和degree 参数的值不同。
[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时,不应该忽略所有度的值吗?
【问题讨论】:
标签: machine-learning scikit-learn svm grid-search