使用Python中的最佳参数进行双重交叉验证

时间:2015-03-09 11:53:31

标签: python scikit-learn

我想使用GridSearchCV使用带有最佳参数的双重交叉验证来训练SVM分类器。直到我在文档之后做了类似的事情但似乎错了。我有两个包含数据和标签的列表,其中每个列表的每个元素分别是一个包含数据和标签的数组:

import sklearn
kf_total = cross_validation.KFold(len(data), n_folds=2, indices=True, shuffle=False, random_state=4)
C = SVC()
[C.fit(data[train_indices], labels[train_indices]).score(data[test_indices],labels[test_indices])
for train_indices, test_indices in kf_total]

len(data) = 4300
data[0] = array([[1, 2, 3],
                 [4, 5, 6],
                 [7, 8, 9],
             ...,
                 [1, 2, 3],
                 [4, 5, 6],
                 [7, 8, 9],  

label[0] = 1
label[1] = 2 . . . . label[4299] = 60

这是对的吗?如何使用GridSearchCV使用最佳参数调整它?

0 个答案:

没有答案
相关问题