def run():
    # train_files, train_labels = read_data_file('./train_test_data_combined.txt')
    data_set, data_labels = load_test_set('./IRMAS-TrainingData/')

    train_files, test_files, train_labels, test_labels = train_test_split(data_set, data_labels, test_size=0.25)

    train_set, train_labels, test_set, test_labels = fit_train_test(train_files, train_labels, test_files,
                                                                    test_labels)

    print("test_labels length: ", len(test_labels))
    print("test_files length: ", len(test_files))
    print()
    print("train_labels length: ", len(train_labels))
    print("train_files length: ", len(train_files))
    print()

    train_classes, encoded_classes = label_encoder(train_labels)
    test_classes = label_encoder_for_test(encoded_classes, test_labels)

    train_set = get_feature_vector_2(train_files)
    test_set = get_feature_vector_2(test_files)

    # linear_regression(train_set, train_classes, test_set, test_classes, encoded_classes)
    knn(train_set, train_classes, test_set, test_classes, encoded_classes)
    svm(train_set, train_classes, test_set, test_classes, encoded_classes)
    random_forest(train_set, train_classes, test_set, test_classes, encoded_classes)
Example #2
0
def run():
    # train_files, train_labels = read_data_file('./train_test_data_combined.txt')
    train_files, train_labels = load_train_set('./IRMAS-TrainingData/',
                                               single_instrument=True)

    train_set = get_feature_vector(train_files)

    song_name = "(02) dont kill the whale-1"
    test_files, test_labels = cut_a_single_song(
        f'./IRMAS-TestingData/Part1/{song_name}')

    print("test_labels length: ", len(test_labels))
    print("test_files length: ", len(test_files))
    print()
    print("train_labels length: ", len(train_labels))
    print("train_files length: ", len(train_files))
    #
    train_classes, encoded_classes = label_encoder(train_labels)
    test_classes = label_encoder_for_test(encoded_classes, test_labels)

    test_set = get_feature_vector_2(test_files)

    knn(train_set, train_classes, test_set, test_classes, encoded_classes)
    svm(train_set, train_classes, test_set, test_classes, encoded_classes)
    random_forest(train_set, train_classes, test_set, test_classes,
                  encoded_classes)
Example #3
0
def run():
    # train_files, train_labels = load_train_set('./data-set/')
    train_files, train_labels = read_data_file()

    test_files, test_labels = load_test_set('./IRMAS-TrainingData/')

    train_files, train_labels, test_files, test_labels = fit_train_test(
        train_files, train_labels, test_files, test_labels)

    print("test_labels length: ", len(test_labels))
    print("test_files length: ", len(test_files))
    print()
    print("train_labels length: ", len(train_labels))
    print("train_files length: ", len(train_files))

    train_classes, encoded_classes = label_encoder(train_labels)
    test_classes = label_encoder_for_test(encoded_classes, test_labels)

    # train_set = get_feature_vector(train_files)
    train_set = train_files
    test_set = get_feature_vector(test_files)

    # read_write_data.create_data_file(train_set, train_labels)

    knn(train_set, train_classes, test_set, test_classes, encoded_classes)
    svm(train_set, train_classes, test_set, test_classes, encoded_classes)
    random_forest(train_set, train_classes, test_set, test_classes,
                  encoded_classes)
    adaboost(train_set, train_classes, test_set, test_classes, encoded_classes)
Example #4
0
def run():
    data_set, data_labels = read_data_file('./train_test_data_combined.txt')

    train_files, test_files, train_labels, test_labels = train_test_split(data_set, data_labels, test_size=0.25)

    train_set, train_labels, test_set, test_labels = fit_train_test(train_files, train_labels, test_files,
                                                                    test_labels)

    train_classes, encoded_classes = label_encoder(train_labels)
    test_classes = label_encoder_for_test(encoded_classes, test_labels)

    knn(train_set, train_classes, test_set, test_classes, encoded_classes)
    svm(train_set, train_classes, test_set, test_classes, encoded_classes)
    random_forest(train_set, train_classes, test_set, test_classes, encoded_classes)
Example #5
0
def run():
    data_set, data_labels = load_by_genre(path='./IRMAS-TrainingData/')

    X = get_feature_vector_2(data_set)

    train_set, test_set, train_labels, test_labels = train_test_split(
        X, data_labels, test_size=0.25)

    train_set, train_labels, test_set, test_labels = fit_train_test(
        train_set, train_labels, test_set, test_labels)

    train_classes, encoded_classes = label_encoder(train_labels)
    test_classes = label_encoder_for_test(encoded_classes, test_labels)

    knn(train_set, train_classes, test_set, test_classes, encoded_classes)
    svm(train_set, train_classes, test_set, test_classes, encoded_classes)
    random_forest(train_set, train_classes, test_set, test_classes,
                  encoded_classes)
    adaboost(train_set, train_classes, test_set, test_classes, encoded_classes)
def run():
    data_set, data_labels = load_train_set('./IRMAS-TrainingData/')
    data_set, data_labels = load_test_set()

    train_files, test_files, train_labels, test_labels = train_test_split(
        data_set, data_labels, test_size=0.25)

    train_files, train_labels, test_files, test_labels = fit_train_test(
        train_files, train_labels, test_files, test_labels)

    train_classes, encoded_classes = label_encoder(train_labels)
    test_classes = label_encoder_for_test(encoded_classes, test_labels)

    train_set = get_feature_vector(train_files)
    test_set = get_feature_vector(test_files)

    knn(train_set, train_classes, test_set, test_classes, encoded_classes)
    svm(train_set, train_classes, test_set, test_classes, encoded_classes)
    random_forest(train_set, train_classes, test_set, test_classes,
                  encoded_classes)
    adaboost(train_set, train_classes, test_set, test_classes, encoded_classes)
Example #7
0
def run():
    # data_set, data_labels = load_train_set('./data-set/')
    data_set, data_labels = read_data_file()

    train_files, test_files, train_labels, test_labels = train_test_split(
        data_set, data_labels, test_size=0.25)

    train_files, train_labels, test_files, test_labels = fit_train_test(
        train_files, train_labels, test_files, test_labels)

    train_classes, encoded_classes = label_encoder(train_labels)
    test_classes = label_encoder_for_test(encoded_classes, test_labels)

    # train_set = get_feature_vector(train_files)
    train_set = train_files
    test_set = test_files
    # test_set = get_feature_vector(test_files)

    knn(train_set, train_classes, test_set, test_classes, encoded_classes)
    svm(train_set, train_classes, test_set, test_classes, encoded_classes)
    random_forest(train_set, train_classes, test_set, test_classes,
                  encoded_classes)
    adaboost(train_set, train_classes, test_set, test_classes, encoded_classes)