def Supervised(filename, old_files = [], stop='', stopat=1, error='none', interval = 100000, starting =1, seed=0, step =10, learner='svm_linear', boost=None): print("FILENAME: ", filename, "OLDFILES: ", len(old_files)) stopat = float(stopat) np.random.seed(seed) read = MAR() read = read.create(filename, old_files) read.step = step read.interval = interval read.seed = seed if boost: util.vote(read, clf_name=boost, seed=seed, all=False, temp=str(seed) + filename) return num2 = read.get_allpos() target = int(num2 * stopat) if stop == 'est': read.enable_est = True else: read.enable_est = False if boost == None: read.train_supervised(learner, seed) pos, neg, total = read.get_numbers() if boost: read.query_boost() else: read.query_supervised() read.record['est'][0] = read.est_num while True: pos, neg, total = read.get_numbers() # try: # print("%d, %d, %d" %(pos,pos+neg, read.est_num)) # except: # print("%d, %d" %(pos,pos+neg)) if pos + neg >= total: break # if pos >= target and (pos+neg) >= total * .22 and read.enable_est and read.est_num*stopat<= pos: # break if boost: ids = read.query_boost()[:read.step] else: ids = read.query_supervised()[:read.step] read.code_batch(ids) return read
def TEST_AL(filename, old_files=[], stop='est', stopat=1, error='none', interval=100000, starting=1, seed=0, step=10): stopat = float(stopat) thres = 0 counter = 0 pos_last = 0 np.random.seed(seed) read = MAR() read = read.create(filename, old_files) read.step = step read.interval = interval num2 = read.get_allpos() target = int(num2 * stopat) if stop == 'est': read.enable_est = True else: read.enable_est = False while True: pos, neg, total = read.get_numbers() try: print("%d, %d, %d" % (pos, pos + neg, read.est_num)) except: print("%d, %d" % (pos, pos + neg)) if pos + neg >= total: break if pos < starting or pos + neg < thres: for id in read.random(): read.code_error(id, error=error) else: a, b, c, d = read.train(weighting=True, pne=True) if pos >= target and read.est_num * stopat <= pos: break for id in c: read.code_error(id, error=error) # read.export() # results = analyze(read) # print(results) # read.plot() return read
def Supervised(filename, old_files=[], stop='est', stopat=1, error='none', interval=100000, starting=1, seed=0, step=10): stopat = float(stopat) np.random.seed(seed) read = MAR() read = read.create(filename, old_files) read.step = step read.interval = interval num2 = read.get_allpos() target = int(num2 * stopat) if stop == 'est': read.enable_est = True else: read.enable_est = False read.train_supervised() pos, neg, total = read.get_numbers() read.query_supervised() read.record['est'][0] = read.est_num while True: pos, neg, total = read.get_numbers() try: print("%d, %d, %d" % (pos, pos + neg, read.est_num)) except: print("%d, %d" % (pos, pos + neg)) if pos + neg >= total: break if pos >= target and read.est_num * stopat <= pos: break for id in read.query_supervised()[:read.step]: read.code_error(id, error=error) return read
def Boosting(filename, old_files = [], stop='', stopat=1, error='none', interval = 100000, starting =1, seed=0, step =10): print("FILENAME: ", filename, "OLDFILES: ", len(old_files)) stopat = float(stopat) np.random.seed(seed) read = MAR() read = read.create(filename,old_files) read.step = step read.interval = interval util.vote(read) num2 = read.get_allpos() target = int(num2 * stopat) if stop == 'est': read.enable_est = True else: read.enable_est = False pos, neg, total = read.get_numbers() read.query_boost() read.record['est'][0]= read.est_num while True: pos, neg, total = read.get_numbers() try: print("%d, %d, %d" %(pos,pos+neg, read.est_num)) except: print("%d, %d" %(pos,pos+neg)) if pos + neg >= total: break if read.enable_est and read.est_num*stopat<= pos: break for id in read.query_boost()[:read.step]: read.code_error(id, error=error) return read