예제 #1
0
def predict(predictor, examples, param):
    """
	make prediction on examples using trained predictor

	@param predictor: trained predictor
	@type predictor: SVM object
	@param examples: list of examples
	@type examples: list 
	"""

    #shogun data
    feat = create_hashed_features_wdk(param.flags, examples)

    #predict
    svm_out = predictor.classify(feat).get_labels()

    return svm_out
예제 #2
0
def train_splice_predictor(examples, labels, param):
    """

	@param examples: list of strings
	@param labels: list of integers {-1,1}
	"""

    ##########################
    #   build classifier
    ##########################

    feat_train = create_hashed_features_wdk(param.flags, examples)
    lab = create_labels(labels)
    svm = create_svm(param, feat_train, lab)

    svm.train()

    return svm
예제 #3
0
def init_predictor(examples, labels, param, w):
    """

	@param examples: list of strings
	@param labels: list of integers {-1,1}
	@param w: weight vector of trained svm
	"""

    ##########################
    #   build classifier
    ##########################

    feat_train = create_hashed_features_wdk(param.flags, examples)
    lab = create_labels(labels)
    svm = create_svm(param, feat_train, lab)

    svm.set_w(w)

    return svm