Ejemplo n.º 1
0
    def _liblinear_train(self, lbls, vecs):
        if MODEL_SEARCH:
            # XXX: Will give BOTH c and model...
            raise NotImplementedError
        else:
            model_type = 0
            
        # Find C
        if C_SEARCH:
            c = _c_search(lbls, vecs, model_type=model_type)
            if C_VERBOSE:
                print >> stderr, 'Found C:', c
        else:
            c = 1

        # Train the model
        from linearutil import (train as liblinear_train,
                problem as liblinear_problem,
                parameter as liblinear_parameter)
        self.model = liblinear_train(liblinear_problem(lbls, vecs),
                liblinear_parameter(
                    '-q -s {0} -c {1}'.format(model_type, 2 ** c)))
Ejemplo n.º 2
0
def _liblinear_train(lbls, vecs, model_type, c):
    from linearutil import (train as liblinear_train,
            problem as liblinear_problem, parameter as liblinear_parameter)
    return liblinear_train(liblinear_problem(lbls, vecs),
            liblinear_parameter('-q -s {0} -c {1}'.format(model_type, c)))