replicahq / doppelganger

A Python package of tools to support population synthesizers
Apache License 2.0
165 stars 32 forks source link

doppelganger.person_structure -> pomegranite.BayesianNetwork #30

Closed nikisix closed 6 years ago

nikisix commented 6 years ago

Running into the following error when trying to train the bayesnet from the simple example notebook.

    194                 # Make defensive copy
    195                 data = list(data) + list(prior_data)
--> 196             bayesian_network = BayesianNetwork.from_structure(data, structure)
    197             type_to_network[type_] = bayesian_network
    198         return BayesianNetworkModel(type_to_network, fields, segmenter=input_data.segmenter)

pomegranate/BayesianNetwork.pyx in pomegranate.BayesianNetwork.BayesianNetwork.from_structure()

TypeError: unsupported operand type(s) for +: 'frozenset' and 'tuple'

Seems to be coming from the following line in pomegranate's BayesianNetwork.pyx -- line 820

    nodes[i] = ConditionalProbabilityTable.from_samples(X[:,parents+(i,)],
        parents=[nodes[parent] for parent in parents],
        weights=weights, pseudocount=pseudocount)

Where i and parents are directly from Doppelganger's configuration.person_structure,

for i, parents in enumerate(structure):

Anyone else come across this one? I've tried upgrading pomegranate to 0.7.7 and installing from source (ignoring pip's cache) and still get the same issue. Setup: OSX Yosemite, pomegranate 0.7.1

katbusch commented 6 years ago

Thanks for the report! This looks like it's from #22. The frozenset was added because test_load_bayes_net was failing. If we need tuples for pomegranate to work, we should change them to tuples, check for duplicates on creation, and change test_load_bayes_net to ignore order.