2018-11-30
阅读量:
827
决策函数
SVC
和NuSVC
为多元分类实现了 “one-against-one” 的方法 (Knerr et al., 1990) 如果n_class
是类别的数量, 那么n_class*(n_class-1)/2
分类器被重构, 而且每一个从两个类别中训练数据. 为了给其他分类器提供一致的交互,decision_function_shape
选项允许聚合 “one-against-one” 分类器的结果成(n_samples,n_classes)
的大小到决策函数:
>>> X = [[0], [1], [2], [3]]
>>> Y = [0, 1, 2, 3]
>>> clf = svm.SVC(decision_function_shape='ovo')
>>> clf.fit(X, Y)
SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,
decision_function_shape='ovo', degree=3, gamma='auto', kernel='rbf',
max_iter=-1, probability=False, random_state=None, shrinking=True,
tol=0.001, verbose=False)
>>> dec = clf.decision_function([[1]])
>>> dec.shape[1] # 4 classes: 4*3/2 = 6
6
>>> clf.decision_function_shape = "ovr"
>>> dec = clf.decision_function([[1]])
>>> dec.shape[1] # 4 classes
4






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论