Scikit learn 如何使用GridSearchCV进行一类分类
我尝试使用GridSearchCV,以便为分类器提供最佳参数。我使用的是单类SVM,我的代码是:Scikit learn 如何使用GridSearchCV进行一类分类,scikit-learn,svm,gridsearchcv,Scikit Learn,Svm,Gridsearchcv,我尝试使用GridSearchCV,以便为分类器提供最佳参数。我使用的是单类SVM,我的代码是: tuned_parameters = [{'kernel': ['rbf'], 'gamma': [1e-2, 1e-3, 1e-4, 1e-5], 'nu': [0.001, 0.10, 0.1, 10, 25, 50, 100, 1000]}, {'kernel': ['linear'], 'nu': [0.001, 0.10,
tuned_parameters = [{'kernel': ['rbf'], 'gamma': [1e-2, 1e-3, 1e-4, 1e-5],
'nu': [0.001, 0.10, 0.1, 10, 25, 50, 100, 1000]},
{'kernel': ['linear'], 'nu': [0.001, 0.10, 0.1, 10, 25, 50, 100, 1000]}
]
scores = ['precision', 'recall']
for score in scores:
print("# Tuning hyper-parameters for %s" % score)
print()
clf = GridSearchCV(svm.OneClassSVM(), tuned_parameters,
scoring='%s_macro' % score)
clf.fit(input_dataN)
我有错误:
TypeError: __call__() missing 1 required positional argument: 'y_true'
请如何修复它?当您应用fit方法时,您需要提供您的功能(X\U系列)以及您的目标类标签(y\U系列): 修正这一行:
clf.fit(input_dataN)
我用了一个等级分类,我没有你的训练。如果你只有正面的标签,那么你只能这样做。