Exemplo n.º 1
0
def test_project_unlabeled_and_tfidf(test_project_data, test_tfidf_matrix,
                                     tmpdir, settings):
    data_temp = tmpdir.mkdir('data').mkdir('tf_idf')
    settings.TF_IDF_PATH = str(data_temp)

    save_tfidf_matrix(test_tfidf_matrix, test_project_data.pk)

    return test_project_data
Exemplo n.º 2
0
def test_project_labeled_and_tfidf(test_project_labeled,
                                   test_tfidf_matrix_labeled,
                                   test_tfidf_vectorizer_labeled, tmpdir,
                                   settings):
    data_temp = tmpdir.mkdir('data').mkdir('tf_idf')
    settings.TF_IDF_PATH = str(data_temp)
    save_tfidf_matrix(test_tfidf_matrix_labeled, test_project_labeled.pk)
    save_tfidf_vectorizer(test_tfidf_vectorizer_labeled,
                          test_project_labeled.pk)
    return test_project_labeled
Exemplo n.º 3
0
def test_project_gnb_data_tfidf(db, test_profile, tmpdir, settings):
    """This fixture only creates the test project without any data."""
    proj = create_project("test_project", test_profile, classifier="gnb")
    test_data = read_test_data_backend(file="./core/data/test_files/test_no_labels.csv")
    add_data(proj, test_data)

    Data.objects.filter(project=proj)
    matrix = create_tfidf_matrix(proj.pk)[0]

    data_temp = tmpdir.mkdir("data").mkdir("tf_idf")
    settings.TF_IDF_PATH = str(data_temp)

    save_tfidf_matrix(matrix, proj.pk)
    return proj
Exemplo n.º 4
0
def test_project_svm_data_tfidf(db, test_profile, tmpdir, settings):
    '''
    This fixture only creates the test project without any data.
    '''
    proj = create_project('test_project', test_profile, classifier="svm")
    test_data = read_test_data_backend(
        file='./core/data/test_files/test_no_labels.csv')
    add_data(proj, test_data)

    Data.objects.filter(project=proj)
    matrix = create_tfidf_matrix(proj.pk)[0]

    data_temp = tmpdir.mkdir('data').mkdir('tf_idf')
    settings.TF_IDF_PATH = str(data_temp)

    save_tfidf_matrix(matrix, proj.pk)

    return proj
Exemplo n.º 5
0
def send_tfidf_creation_task(project_pk):
    """Create and Save tfidf"""
    from core.utils.utils_model import create_tfidf_matrix, save_tfidf_matrix, save_tfidf_vectorizer

    tf_idf, vectorizer = create_tfidf_matrix(project_pk)
    file = save_tfidf_matrix(tf_idf, project_pk)
    save_tfidf_vectorizer(vectorizer, project_pk)

    return file
Exemplo n.º 6
0
def test_save_tfidf_matrix(test_project_data, test_tfidf_matrix, tmpdir,
                           settings):
    data_temp = tmpdir.mkdir('data').mkdir('tf_idf')
    settings.TF_IDF_PATH = str(data_temp)

    file = save_tfidf_matrix(test_tfidf_matrix, test_project_data.pk)

    assert os.path.isfile(file)
    assert file == os.path.join(
        settings.TF_IDF_PATH,
        'project_' + str(test_project_data.pk) + '_tfidf_matrix.pkl')
def test_save_tfidf_matrix(test_project_data, test_tfidf_matrix, tmpdir, settings):
    data_temp = tmpdir.mkdir("data").mkdir("tf_idf")
    settings.TF_IDF_PATH = str(data_temp)

    file = save_tfidf_matrix(test_tfidf_matrix, test_project_data.pk)

    assert os.path.isfile(file)
    assert file == os.path.join(
        settings.TF_IDF_PATH,
        "project_" + str(test_project_data.pk) + "_tfidf_matrix.pkl",
    )