Esempio n. 1
0
def test_wasserstein_vectorizer_lists():
    vectorizer = WassersteinVectorizer(random_state=42)
    result = vectorizer.fit_transform(distributions_data_list,
                                      vectors=vectors_data_list)
    transform_result = vectorizer.transform(distributions_data_list,
                                            vectors=vectors_data_list)
    assert np.allclose(result, transform_result, rtol=1e-3, atol=1e-6)
Esempio n. 2
0
def test_wasserstein_vectorizer_list_based_blockwise():
    lil_data = normalize(distributions_data, norm="l1").tolil()
    distributions = [np.array(x) for x in lil_data.data]
    vectors = [vectors_data[x] for x in lil_data.rows]
    vectorizer = WassersteinVectorizer(random_state=42, memory_size="50k")
    result = vectorizer.fit_transform(distributions, vectors=vectors)
    transform_result = vectorizer.transform(distributions, vectors=vectors)
    assert np.allclose(result, transform_result, rtol=1e-3, atol=1e-6)
Esempio n. 3
0
def test_wasserstein_vectorizer_generators_blockwise():
    distributions_data_generator = (x for x in distributions_data_list)
    vectors_data_generator = (x for x in vectors_data_list)
    vectorizer = WassersteinVectorizer(random_state=42, memory_size="50k")
    result = vectorizer.fit_transform(
        distributions_data_generator,
        vectors=vectors_data_generator,
        reference_distribution=generator_reference_dist,
        reference_vectors=generator_reference_vectors,
        n_distributions=distributions_data.shape[0],
        vector_dim=vectors_data.shape[1],
    )
    distributions_data_generator = (x for x in distributions_data_list)
    vectors_data_generator = (x for x in vectors_data_list)
    transform_result = vectorizer.transform(
        distributions_data_generator,
        vectors=vectors_data_generator,
        n_distributions=distributions_data.shape[0],
        vector_dim=vectors_data.shape[1],
    )
    assert np.allclose(result, transform_result, rtol=1e-3, atol=1e-6)
Esempio n. 4
0
def test_wasserstein_vectorizer_blockwise():
    vectorizer = WassersteinVectorizer(random_state=42, memory_size="50k")
    result = vectorizer.fit_transform(distributions_data, vectors=vectors_data)
    transform_result = vectorizer.transform(distributions_data, vectors=vectors_data)
    assert np.allclose(result, transform_result, rtol=1e-3, atol=1e-6)