我不确定我问的是否可行,但我希望能够使用所有参数定义SVM类,然后将其传递给SVM方法 .

我的最终目标是创建一个基本的GUI,允许用户使用按钮更改SVM的不同参数,我想不出任何其他方法来实现这一点 .

如果我对此采取完全错误的方式,我也会对如何实现这一点提出任何其他建议 .

先感谢您 .

class SupportVectorMachine:

    def __init__(self, C, cache_size, class_weight, coef0, decision_function_shape, degree, gamma, kernel, max_iter, probability, random_state, shrinking, tol, verbose):
        self.C = C
        self.cache_size = cache_size
        self.class_weight = class_weight
        self.coef0 = coef0
        self.decision_function_shape = decision_function_shape
        self.degree = degree
        self.gamma = gamma
        self.kernel = kernel
        self.max_iter = max_iter
        self.probability = probability
        self.random_state = random_state
        self.shrinking = shrinking
        self.tol = tol
        self.verbose = verbose


    DefaultSVM = SupportVectorMachine(1.0, 200, None, 0.0, 'ovr', 3, 'auto', 'rbf', -1, False, None, True, 0.001, False)


    def support_vector_machine():
        x = training_data
        y = training_labels
        clf = svm.SVC()
        clf.fit(x,y)
        print(clf)