Esempio n. 1
0
def test_distributions_uniform_kernel_random_sample():
	d = BernoulliDistribution(0.2)

	x = numpy.array([0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 
			0, 0, 0, 0, 0])

	assert_array_equal(d.sample(20, random_state=5), x)
	assert_raises(AssertionError, assert_array_equal, d.sample(20), x)
Esempio n. 2
0
def test_distributions_uniform_kernel_random_sample():
	d = BernoulliDistribution(0.2)

	x = numpy.array([0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 
			0, 0, 0, 0, 0])

	assert_array_equal(d.sample(20, random_state=5), x)
	assert_raises(AssertionError, assert_array_equal, d.sample(20), x)
Esempio n. 3
0
File: main.py Progetto: tsameti/dbns
from pomegranate import (
    NaiveBayes,
    NormalDistribution,
    UniformDistribution,
    ExponentialDistribution,
    GeneralMixtureModel,
    MultivariateGaussianDistribution,
    BernoulliDistribution,
)
import pandas as pd
import numpy as np

X = pd.DataFrame({"A": [1, 0, 1, 0, 1], "B": [1, 1, 1, 1, 0]})

x = BernoulliDistribution(0.4)

vals = []
[vals.append(x.sample()) for i in range(1000)]

model = NaiveBayes([
    NormalDistribution(5, 2),
    UniformDistribution(0, 10),
    ExponentialDistribution(1.0)
])
model.predict(np.array([[10]]))

model = GeneralMixtureModel.from_samples(MultivariateGaussianDistribution,
                                         n_components=3,
                                         X=X)