Example #1
0
def training(a, b, problem, story, target, j, order, score, constraints):
    #this function take the trips and creates positive and negative training
    # instances from them
    if j == 0:
        j = -1
    vec = [j, order, score, constraints]
    vec.extend(makesets.eqvector(a, b, problem, story, target))

    return vec
Example #2
0
def training(trips, problem, story, target, sets):
    #this function take the trips and creates positive and negative training instances from them

    texamples = {x: ([], []) for x in ["+", "*", '/', '-', '=']}
    for op, a, b in trips:
        if op == '=':
            vec = makesets.eqvector(a, b, problem, story, target, sets)
        else:
            vec = makesets.vector(a, b, problem, story, target)
        texamples[op][0].append(vec)

    return texamples
Example #3
0
def training(trips, problem, story, target):
    # this function take the trips and creates positive and negative training instances from them

    texamples = {x: ([], []) for x in ["+", "*", "/", "-", "="]}
    for op, a, b in trips:
        if op == "=":
            vec = makesets.eqvector(a, b, problem, story, target)
        else:
            vec = makesets.vector(a, b, problem, story, target)
        texamples[op][0].append(vec)

    return texamples
Example #4
0
def compute(p,op,e,target,problem,story,order,sp=None):
    if op == '==':
        vec = [order].extend(makesets.eqvector(p,e,problem,story,target,sp))
        op_label, op_acc, op_val = svm_predict([-1], [vec], glob ,'-q -b 1')
    else:
        vec = makesets.vector(p,e,problem,story,target)
        op_label, op_acc, op_val = svm_predict([-1], [vec], multi ,'-q -b 1')

    op_val=op_val[0]
    if op == '+':
        val = op_val[0]
    if op == '-':
        val = op_val[1]
    if op == '*':
        val = op_val[2]
    if op == '/':
        val = op_val[3]
    if op == '=':
        val = op_val[1]


    c = makesets.combine(p[1],e[1],op)
    return (val,c,op_val)