コード例 #1
0
class IncrementalSVM_MultiHack(object):

    def __init__(self, l2_regularization):
        self.l2_regularization = l2_regularization

    def fit(self, x, y, history):
        self._svm = IncrementalMultiSVM(
                dtype=x.dtype,
                n_features=x.shape[1],
                n_classes=2,
                l2_regularization=self.l2_regularization,
                n_sgd_iters=0,
                bfgs_kwargs={
                    'maxfun': 1000,
                    'iprint': 0,
                    'm': 32,
                    'factr': 100},
                )
        self._svm.fit(x, (y + 1) / 2, history)

    def predict(self, x, history):
        return self._svm.predict(x, history) * 2 - 1
コード例 #2
0
class IncrementalSVM_MultiHack(object):
    def __init__(self, l2_regularization):
        self.l2_regularization = l2_regularization

    def fit(self, x, y, history):
        self._svm = IncrementalMultiSVM(
            dtype=x.dtype,
            n_features=x.shape[1],
            n_classes=2,
            l2_regularization=self.l2_regularization,
            n_sgd_iters=0,
            bfgs_kwargs={
                'maxfun': 1000,
                'iprint': 0,
                'm': 32,
                'factr': 100
            },
        )
        self._svm.fit(x, (y + 1) / 2, history)

    def predict(self, x, history):
        return self._svm.predict(x, history) * 2 - 1