def run():
    # Crop out facial images and retrieve features. Ideally, one only need to call this function once.
    prepare_data.run()

    # Make prediction by using different features
    for facial_image_extension, feature_extension in itertools.product(\
                prepare_data.FACIAL_IMAGE_EXTENSION_LIST, prepare_data.FEATURE_EXTENSION_LIST):
        make_prediction(facial_image_extension, feature_extension)

    print("All done!")
Beispiel #2
0
def run():
    # Crop out facial images and retrieve features. Ideally, one only need to call this function once.
    prepare_data.run()

    # Make prediction by using different features
    for facial_image_extension, feature_extension in itertools.product(\
                prepare_data.FACIAL_IMAGE_EXTENSION_LIST, prepare_data.FEATURE_EXTENSION_LIST):
        make_prediction(facial_image_extension, feature_extension)

    print("All done!")
def run_all(userid_, songids_, K):
    """
    runs the prepare_data functions
    to create datasets and then runs the
    knn C++ program to get results written to file and then
    reads the file written to by running the C++ program

    Return: Returns a dict with the songids and the corresponding
            predictions
    """
    filename_ = prepare_data.run(userid_, songids_)
    num_queries = len(songids_)
    outfile = DATADIR_ + userid_ + "_output"
    command = (
        "/home/tathagata/SmartPlayerModules/Audio/audiomodules/KNN/KNN/KNN_c/k-classifier\
    "
        + filename_
        + " "
        + str(K)
        + "\
    "
        + str(num_queries)
        + " > "
        + outfile
    )

    # subprocess.call blocks until command has completed
    subprocess.call(command, 0, None, None, None, None, None, False, True)

    return read_knn_out(outfile)
def run_all(userid_, songids_, K):
    """
    runs the prepare_data functions
    to create datasets and then runs the
    knn C++ program to get results written to file and then
    reads the file written to by running the C++ program

    Return: Returns a dict with the songids and the corresponding
            predictions
    """
    trainfile_, testfile_ = prepare_data.run(userid_, songids_)
    print(trainfile_)
    print(testfile_)
    outfile = DATADIR_ + userid_ + '_output'
    command = '/home/tathagata/SmartPlayerModules/Audio/audiomodules/KNN/KNN/KNN_c/knn ' + trainfile_ + ' ' + testfile_ + ' ' + str(K) + '\
     > ' + outfile
    # subprocess.call blocks until command has completed
    subprocess.call(command, 0, None, None, None, None, None, False, True)

    return read_knn_out(outfile)
Beispiel #5
0
def run_model_LR(Base_Dir_40p208, Base_Dir_share, date):
    # sys.path.append(Base_Dir_40p208 + '/model_LR')
    import prepare_data
    import offline_exp

    # conf = get_conf.run(Base_Dir_40p208, date, cid, bid, "1")
    # if conf.has_key("model_LR"):
    #     conf = conf["model_LR"]
    # else:
    #     print "run_model.py - run_model_LR() : cid-{0}, bid-{1} has no model_LR section.".format(cid, bid)
    #     exit()
    conf = conf_dict
    conf_format = {}
    conf_format["General"] = {}
    for k in conf:
        if k == "select_features":
            conf_format["General"][k] = conf[k]
            continue
        if k == "sample_proportion":
            conf_format["General"][k] = conf[k]
            continue
        if k == "sample":
            conf_format["General"][k] = conf[k]
            continue
        if k == "train_days":
            conf_format["General"][k] = conf[k]
            continue
        if k == "test_days":
            conf_format["General"][k] = conf[k]
            continue
        conf_format[k] = conf[k]

    train_list, test_list = prepare_data.run(Base_Dir_40p208, Base_Dir_share, date, cid, bid, conf_format)
    print train_list
    print test_list

    offline_exp.run(Base_Dir_40p208, date, cid, bid, conf_format, train_list, test_list)
Beispiel #6
0
def run_model_LR(Base_Dir_40p208, Base_Dir_share, cid, bid, date):
    sys.path.append(Base_Dir_40p208 + '/model_LR')
    import prepare_data
    import offline_exp

    conf = get_conf.run(Base_Dir_40p208, date, cid, bid, "1")
    if conf.has_key("model_LR"):
        conf = conf["model_LR"]
    else:
        print "run_model.py - run_model_LR() : cid-{0}, bid-{1} has no model_LR section.".format(cid, bid)
        exit()

    conf_format = {}
    conf_format["General"] = {}
    for k in conf:
        if k == "select_features":
            conf_format["General"][k] = conf[k]
            continue
        if k == "sample_proportion":
            conf_format["General"][k] = conf[k]
            continue
        if k == "sample":
            conf_format["General"][k] = conf[k]
            continue
        if k == "train_days":
            conf_format["General"][k] = conf[k]
            continue
        if k == "test_days":
            conf_format["General"][k] = conf[k]
            continue
        conf_format[k] = conf[k]

    train_list, test_list = prepare_data.run(Base_Dir_40p208, Base_Dir_share, date, cid, bid, conf_format)
    print train_list
    print test_list

    offline_exp.run(Base_Dir_40p208, date, cid, bid, conf_format, train_list, test_list)