예제 #1
0
파일: learn.py 프로젝트: zclfly/whereami
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()
예제 #2
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(3)
        try:
            new_sample = sample(device)
            if new_sample:
                write_data(label_path, new_sample)
        except KeyboardInterrupt:  # pragma: no cover
            break
예제 #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()
예제 #4
0
def predictprint(input_path=None, model_path=None, device=""):
    lp = get_model(model_path)
    data_sample = sample(
        device) if input_path is None else get_external_sample(input_path)
    return json.dumps(dict(zip(lp.classes_, lp.predict_proba(data_sample)[0])))
예제 #5
0
def predict(input_path=None, model_path=None, device=""):
    lp = get_model(model_path)
    data_sample = sample(
        device) if input_path is None else get_external_sample(input_path)
    return lp.predict(data_sample)[0]
예제 #6
0
def predict_proba():
    lp = get_model()
    print({x: y for x, y in zip(lp.classes_, lp.predict_proba(sample())[0])})
예제 #7
0
def predict():
    lp = get_model()
    return lp.predict(sample())[0]
예제 #8
0
def predict():
    lp = get_model()
    print(lp.predict(sample())[0])
from whereami.get_data import sample
from whereami.learn import write_data

sequence1_label_file = "sequence1_label.txt"
sequence1_data_file = "sequence1_data.txt"
sequence2_label_file = "sequence2_label.txt"
sequence2_data_file = "sequence2_data.txt"
sequence1 = ['sy', 'sy_door', 'rail', 'daniel_door', 'daniel']
sequence2 = ['daniel', 'daniel_door', 'rail', 'sy_door', 'sy']
n = 100

for i in range(n):
    for location in sequence2:
        str = "press enter to collect data at " + location
        a = input(str)
        try:
            new_sample = sample()
            if new_sample:
                write_data(sequence2_data_file, new_sample)
                write_data(sequence2_label_file, location)
        except KeyboardInterrupt:  # pragma: no cover
            break