def REUSE(filename, old): stop = 0.9 thres = 5 read = MAR() read = read.create(filename) read.create_old(old) num2 = read.get_allpos() target = int(num2 * stop) while True: pos, neg, total = read.get_numbers() # print("%d/ %d" % (pos,pos+neg)) if pos >= target: break if pos < thres: a, b, ids, c = read.train() for id in ids: read.code(id, read.body["label"][id]) else: a, b, ids, c = read.train_reuse() for id in ids: read.code(id, read.body["label"][id]) return read
def UPDATE_REUSE(filename, old): stop = 0.9 lifes = 2 life = lifes last_pos = 0 thres = 5 read = MAR() read = read.create(filename) read.create_old(old) num2 = read.get_allpos() target = int(num2 * stop) while True: pos, neg, total = read.get_numbers() # print("%d/ %d" % (pos, pos + neg)) if pos - last_pos: life = lifes else: life = life - 1 last_pos = pos if pos >= target: break # if (pos >= thres or pos==0) and life<1: if (pos >= thres) and life < 1: # print("reuse") lifes = 0 a, b, ids, c = read.train_reuse() for id in ids: read.code(id, read.body["label"][id]) else: # print("update") a, b, ids, c = read.train() for id in ids: read.code(id, read.body["label"][id]) return read