Beispiel #1
0
    def test_induced_trees(self):
        add_parametric_inference_support()
        add_parametric_sampling_support()

        spn = 0.5 * (Gaussian(mean=10, stdev=0.000000001, scope=0) * Categorical(p=[1.0, 0], scope=1)) + \
              0.5 * (Gaussian(mean=50, stdev=0.000000001, scope=0) * Categorical(p=[0, 1.0], scope=1))

        rand_gen = np.random.RandomState(17)

        data = np.zeros((2, 2))

        data[1, 1] = 1

        data[:, 0] = np.nan

        sample_instances(spn, data, rand_gen)

        self.assertAlmostEqual(data[0, 0], 10)
        self.assertAlmostEqual(data[1, 0], 50)
Beispiel #2
0
from spn.structure.leaves.histogram.Expectation import add_histogram_expectation_support
from spn.structure.leaves.histogram.Inference import add_histogram_inference_support
from spn.structure.leaves.histogram.MPE import add_histogram_mpe_support
from spn.structure.leaves.parametric.Expectation import add_parametric_expectation_support
from spn.structure.leaves.parametric.Inference import add_parametric_inference_support
from spn.structure.leaves.parametric.MPE import add_parametric_mpe_support
from spn.structure.leaves.parametric.Sampling import add_parametric_sampling_support
from spn.structure.leaves.piecewise.Expectation import add_piecewise_expectation_support
from spn.structure.leaves.piecewise.Inference import add_piecewise_inference_support

add_parametric_sampling_support()
add_parametric_inference_support()
add_parametric_expectation_support()
add_parametric_mpe_support()

add_piecewise_inference_support()
add_piecewise_expectation_support()

add_histogram_inference_support()
add_histogram_expectation_support()
add_histogram_mpe_support()