def svc_rbf(name,
            C=None,
            gamma=None,
            shrinking=None,
            tol=None,
            max_iter=None,
            verbose=False,
            random_state=None,
            cache_size=_svc_default_cache_size):
    """
    Return a pyll graph with hyperparamters that will construct
    a sklearn.svm.SVC model with an RBF kernel.

    """
    def _name(msg):
        return '%s.%s_%s' % (name, 'rbf', msg)

    rval = scope.sklearn_SVC(
        kernel='rbf',
        C=_svc_C(name + '.rbf') if C is None else C,
        gamma=_svc_gamma(name) if gamma is None else gamma,
        shrinking=hp_bool(
            _name('shrinking')) if shrinking is None else shrinking,
        tol=_svc_tol(name + '.rbf') if tol is None else tol,
        max_iter=(_svc_max_iter(name + '.rbf')
                  if max_iter is None else max_iter),
        verbose=verbose,
        cache_size=cache_size,
        random_state=_random_state(_name('rstate'), random_state),
        )
    return rval
Beispiel #2
0
def svc_rbf(name,
            C=None,
            gamma=None,
            shrinking=None,
            tol=None,
            max_iter=None,
            verbose=False,
            random_state=None,
            cache_size=_svc_default_cache_size):
    """
    Return a pyll graph with hyperparamters that will construct
    a sklearn.svm.SVC model with an RBF kernel.

    """
    def _name(msg):
        return '%s.%s_%s' % (name, 'rbf', msg)

    rval = scope.sklearn_SVC(
        kernel='rbf',
        C=_svc_C(name + '.rbf') if C is None else C,
        gamma=_svc_gamma(name) if gamma is None else gamma,
        shrinking=hp_bool(_name('shrinking'))
        if shrinking is None else shrinking,
        tol=_svc_tol(name + '.rbf') if tol is None else tol,
        max_iter=(_svc_max_iter(name +
                                '.rbf') if max_iter is None else max_iter),
        verbose=verbose,
        cache_size=cache_size,
        random_state=_random_state(_name('rstate'), random_state),
    )
    return rval
Beispiel #3
0
def svc_kernel(name, kernel, random_state=None, **kwargs):
    """
    Return a pyll graph with hyperparamters that will construct
    a sklearn.svm.SVC model with a user specified kernel.

    See help(hpsklearn.components._svm_hp_space) for info on additional SVM
    arguments.
    """
    def _name(msg):
        return '%s.%s_%s' % (name, kernel, msg)

    hp_space = _svm_hp_space(_name, kernel=kernel, **kwargs)
    hp_space.update(_svc_hp_space(_name, random_state))
    return scope.sklearn_SVC(**hp_space)
Beispiel #4
0
def svc_kernel(name, kernel, random_state=None, **kwargs):
    """
    Return a pyll graph with hyperparamters that will construct
    a sklearn.svm.SVC model with a user specified kernel.

    See help(hpsklearn.components._svm_hp_space) for info on additional SVM
    arguments.
    """
    def _name(msg):
        return '%s.%s_%s' % (name, kernel, msg)

    hp_space = _svm_hp_space(_name, kernel=kernel, **kwargs)
    hp_space.update(_svc_hp_space(_name, random_state))
    return scope.sklearn_SVC(**hp_space)
def svc_poly(name,
             C=None,
             gamma=None,
             coef0=None,
             degree=None,
             shrinking=None,
             tol=None,
             max_iter=None,
             verbose=False,
             random_state=None,
             cache_size=_svc_default_cache_size):
    """
    Return a pyll graph with hyperparamters that will construct
    a sklearn.svm.SVC model with an RBF kernel.

    """
    def _name(msg):
        return '%s.%s_%s' % (name, 'poly', msg)

    # -- (K(x, y) + coef0)^d
    coef0nz = hp.choice(_name('coef0nz'), [0, 1])
    coef0 = hp.uniform(_name('coef0'), 0.0, 1.0)
    poly_coef0 = coef0nz * coef0

    rval = scope.sklearn_SVC(
        kernel='poly',
        C=_svc_C(name + '.poly') if C is None else C,
        gamma=_svc_gamma(name + '.poly') if gamma is None else gamma,
        coef0=poly_coef0 if coef0 is None else coef0,
        degree=hp.quniform(
            _name('degree'),
            low=1.5,
            high=8.5,
            q=1) if degree is None else degree,
        shrinking=hp_bool(
            _name('shrinking')) if shrinking is None else shrinking,
        tol=_svc_tol(name + '.poly') if tol is None else tol,
        max_iter=(_svc_max_iter(name + '.poly')
                  if max_iter is None else max_iter),
        verbose=verbose,
        random_state=_random_state(_name('.rstate'), random_state),
        cache_size=cache_size,
        )
    return rval
Beispiel #6
0
def svc_poly(name,
             C=None,
             gamma=None,
             coef0=None,
             degree=None,
             shrinking=None,
             tol=None,
             max_iter=None,
             verbose=False,
             random_state=None,
             cache_size=_svc_default_cache_size):
    """
    Return a pyll graph with hyperparamters that will construct
    a sklearn.svm.SVC model with an RBF kernel.

    """
    def _name(msg):
        return '%s.%s_%s' % (name, 'poly', msg)

    # -- (K(x, y) + coef0)^d
    coef0nz = hp.choice(_name('coef0nz'), [0, 1])
    coef0 = hp.uniform(_name('coef0'), 0.0, 1.0)
    poly_coef0 = coef0nz * coef0

    rval = scope.sklearn_SVC(
        kernel='poly',
        C=_svc_C(name + '.poly') if C is None else C,
        gamma=_svc_gamma(name + '.poly') if gamma is None else gamma,
        coef0=poly_coef0 if coef0 is None else coef0,
        degree=hp.quniform(_name('degree'), low=1.5, high=8.5, q=1)
        if degree is None else degree,
        shrinking=hp_bool(_name('shrinking'))
        if shrinking is None else shrinking,
        tol=_svc_tol(name + '.poly') if tol is None else tol,
        max_iter=(_svc_max_iter(name +
                                '.poly') if max_iter is None else max_iter),
        verbose=verbose,
        random_state=_random_state(_name('.rstate'), random_state),
        cache_size=cache_size,
    )
    return rval
def svc_sigmoid(name,
                C=None,
                gamma=None,
                coef0=None,
                shrinking=None,
                tol=None,
                max_iter=None,
                verbose=False,
                random_state=None,
                cache_size=_svc_default_cache_size):
    """
    Return a pyll graph with hyperparamters that will construct
    a sklearn.svm.SVC model with an RBF kernel.

    """
    def _name(msg):
        return '%s.%s_%s' % (name, 'sigmoid', msg)

    # -- tanh(K(x, y) + coef0)
    coef0nz = hp.choice(_name('coef0nz'), [0, 1])
    coef0 = hp.normal(_name('coef0'), 0.0, 1.0)
    sigm_coef0 = coef0nz * coef0

    rval = scope.sklearn_SVC(
        kernel='sigmoid',
        C=_svc_C(name + '.sigmoid') if C is None else C,
        gamma=_svc_gamma(name + '.sigmoid') if gamma is None else gamma,
        coef0=sigm_coef0 if coef0 is None else coef0,
        shrinking=hp_bool(
            _name('shrinking')) if shrinking is None else shrinking,
        tol=_svc_tol(name + '.sigmoid') if tol is None else tol,
        max_iter=(_svc_max_iter(name + '.sigmoid')
                  if max_iter is None else max_iter),
        verbose=verbose,
        random_state=_random_state(_name('rstate'), random_state),
        cache_size=cache_size)
    return rval
Beispiel #8
0
def svc_sigmoid(name,
                C=None,
                gamma=None,
                coef0=None,
                shrinking=None,
                tol=None,
                max_iter=None,
                verbose=False,
                random_state=None,
                cache_size=_svc_default_cache_size):
    """
    Return a pyll graph with hyperparamters that will construct
    a sklearn.svm.SVC model with an RBF kernel.

    """
    def _name(msg):
        return '%s.%s_%s' % (name, 'sigmoid', msg)

    # -- tanh(K(x, y) + coef0)
    coef0nz = hp.choice(_name('coef0nz'), [0, 1])
    coef0 = hp.normal(_name('coef0'), 0.0, 1.0)
    sigm_coef0 = coef0nz * coef0

    rval = scope.sklearn_SVC(
        kernel='sigmoid',
        C=_svc_C(name + '.sigmoid') if C is None else C,
        gamma=_svc_gamma(name + '.sigmoid') if gamma is None else gamma,
        coef0=sigm_coef0 if coef0 is None else coef0,
        shrinking=hp_bool(_name('shrinking'))
        if shrinking is None else shrinking,
        tol=_svc_tol(name + '.sigmoid') if tol is None else tol,
        max_iter=(_svc_max_iter(name +
                                '.sigmoid') if max_iter is None else max_iter),
        verbose=verbose,
        random_state=_random_state(_name('rstate'), random_state),
        cache_size=cache_size)
    return rval