【发布时间】:2021-12-29 02:03:06
【问题描述】:
我正在尝试将OneClassSVM 与GridSearchCV 一起使用,如下所示:
param_grid={'nu':[0.0001,0.001,0.01,0.1,1],'gamma':[0.0001,0.001,0.01,0.1,1],'kernel':['rbf','poly','linear']}
svc=svm.OneClassSVM()
model=GridSearchCV(svc,param_grid)
但是命令
model.fit(X_train, y_train)
给我错误:
TypeError: If no scoring is specified, the estimator passed should have a 'score' method. The estimator OneClassSVM(cache_size=200, coef0=0.0, degree=3, gamma='scale', kernel='rbf',
max_iter=-1, nu=0.5, shrinking=True, tol=0.001, verbose=False) does not.
附:使用 SVC 而不是 OneClassSVM 有效。
【问题讨论】:
标签: python machine-learning scikit-learn svm gridsearchcv