Example #1
0
def main():
    try:
        parser = get_args_parser()
        args = parser.parse_args()
        if args.command == "predict_proba":
            predict_proba(args.input_path, args.model_path, args.device)
        elif args.command == "predict":
            print(predict(args.input_path, args.model_path, args.device))
        elif args.command == "learn":
            learn(args.location, args.num_samples, args.device)
        elif args.command == "crossval":
            crossval(path=args.model_path)
        elif args.command in ["locations", "ls"]:
            locations(args.model_path)
        elif args.command == "rename":
            rename_label(args.label, args.new_label)
            print("Retraining model...")
            train_model()
        elif args.command == "train":
            train_model(args.model_path)
        else:
            parser.print_help()
            parser.exit(1)
    except (KeyboardInterrupt, SystemExit):
        exit()
Example #2
0
def learn(label, n=100):
    path = ensure_whereami_path()
    label_path = get_label_file(path, label + ".txt")
    for _ in tqdm(range(n)):
        try:
            new_sample = sample()
            if new_sample:
                write_data(label_path, new_sample)
        except KeyboardInterrupt:  # pragma: no cover
            break
    train_model()
Example #3
0
def learn(label, n=100):
    path = ensure_whereami_path()
    label_path = get_label_file(path, label + ".txt")
    file_exists = os.path.isfile(label_path)
    for _ in tqdm(range(n)):
        try:
            data = sample()
            write_data(label_path, data, file_exists)
            file_exists = True
        except KeyboardInterrupt:
            break
    train_model()
Example #4
0
def learn(label, n=1, device=""):
    path = ensure_whereami_path()
    label_path = get_label_file(path, label + ".txt")
    for i in tqdm(range(n)):
        if i != 0:
            time.sleep(15)
        try:
            new_sample = sample(device)
            if new_sample:
                write_data(label_path, new_sample)
        except KeyboardInterrupt:  # pragma: no cover
            break
    train_model()
Example #5
0
def main():
    parser = get_args_parser()
    args = parser.parse_args()
    if args.command == "predict_proba":
        predict_proba()
    elif args.command == "predict":
        print(predict())
    elif args.command == "learn":
        learn(args.location, args.num_samples)
    elif args.command == "crossval":
        crossval()
    elif args.command in ["locations", "ls"]:
        locations()
    elif args.command == "rename":
        rename_label(args.label, args.new_label)
        print("Retraining model...")
        train_model()
    else:
        parser.print_help()
        parser.exit(1)
Example #6
0
    for i in tqdm(range(len(predictions))):
        print(i, predictions[i], labels[i])
        if predictions[i] == labels[i]:
            num_correct = num_correct + 1
    return num_correct / len(predictions)


exp1_source_files = [
    '/home/pi/.whereami/test_data/test_circle_table_west.txt',
    '/home/pi/.whereami/test_data/test_square_table_east.txt',
    '/home/pi/.whereami/test_data/test_thermo_red_square.txt',
    '/home/pi/.whereami/test_data/test_table_1_north_outlet.txt'
]
exp4_source_files = [
    '/home/pi/.whereami/test_data/test_near_base.txt',
    '/home/pi/.whereami/test_data/test_near_two.txt',
    '/home/pi/.whereami/test_data/test_near_one.txt'
]
exp3_source_files = [
    '/home/pi/.whereami/test_data/test_m.txt',
    '/home/pi/.whereami/test_data/test_ms.txt',
    '/home/pi/.whereami/test_data/test_mss.txt'
]
path = '/home/pi/.whereami/test_data'
source_files = [
    os.path.join(path, f) for f in os.listdir(path)
    if os.path.isfile(os.path.join(path, f))
]
train_model(model_type='nn')
print(evaluate_test_acc(source_files))