Esempio n. 1
0
def test_fit_transform():
    """
    Assert that fit_one and transform_one methods returns waited ouput.
    """

    lda = LDA(n_components=2,
              number_of_documents=60,
              vocab_prune_interval=2,
              maximum_size_vocabulary=3,
              seed=42)
    components_list = []

    for document in DOC_SET:
        tokens = {token: 1 for token in document.split(' ')}
        lda = lda.fit_one(x=tokens)

        components_list.append(lda.transform_one(x=tokens))

    for index, component in enumerate(components_list):
        assert np.array_equal(a1=list(component.values()),
                              a2=REFERENCE_FIT_ONE_PREDICT_ONE[index])
Esempio n. 2
0
def test_fit_transform():
    '''
    Assert that fit_one and transform_one methods returns waited ouput.
    '''
    np.random.seed(42)

    online_lda = LDA(
        n_components=2,
        number_of_documents=60,
        vocab_prune_interval=2,
        maximum_size_vocabulary=3,
    )
    components_list = []

    for document in DOC_SET:
        online_lda = online_lda.fit_one(x=document)

        components_list.append(online_lda.transform_one(x=document))

    for index, component in enumerate(components_list):
        assert np.array_equal(a1=list(component.values()),
                              a2=REFERENCE_FIT_ONE_PREDICT_ONE[index])