def test_acyclic_generators():
    for mechanism in mechanisms:
        agg, data = AcyclicGraphGenerator(mechanism,
                                          points=200,
                                          nodes=10,
                                          parents_max=3).generate()
        assert type(agg) == nx.DiGraph
        assert nx.is_directed_acyclic_graph(agg)
def test_noises():
    for noise in [normal_noise, uniform_noise]:
        agg, data = AcyclicGraphGenerator("linear",
                                          points=200,
                                          nodes=10,
                                          parents_max=3,
                                          noise=noise).generate()
        assert type(agg) == nx.DiGraph
        assert nx.is_directed_acyclic_graph(agg)
def test_causes():
    for cause in [gmm_cause, gaussian_cause]:
        agg, data = AcyclicGraphGenerator(
            "linear",
            points=200,
            nodes=10,
            parents_max=3,
            initial_variable_generator=cause).generate()
        assert type(agg) == nx.DiGraph
        assert nx.is_directed_acyclic_graph(agg)
Ejemplo n.º 4
0
    for nb_points in [200,500,1000]:

        for nb_nodes in [20,50,100]:

            for mecanism in mechanisms:
                print(nb_points)
                print(nb_nodes)
                print(mecanism)

                if(mecanism == "linear"):
                    cause = gaussian_cause
                else:
                    cause = gmm_cause

                agg, data = AcyclicGraphGenerator(mecanism, points=nb_points, nodes=nb_nodes, parents_max=5, initial_variable_generator=cause).generate()

                Adj = nx.to_numpy_matrix(agg)



                cpt = 0
                for i in range(Adj.shape[0]):

                    for j in range(Adj.shape[1]):

                        if(Adj[i,j]==1):
                            cpt+=1
                            cause = data["V" + str(i)].values
                            effect = data["V" + str(j)].values
Ejemplo n.º 5
0

from cdt.generators import AcyclicGraphGenerator

for mechanism in ['polynomial','NN','sigmoid_add', 'sigmoid_mix',
                  'gp_add', 'gp_mix', 'linear']:#  'linear', 'sigmoid_add', 'sigmoid_mix',
    a = AcyclicGraphGenerator(mechanism, nodes=20)
    a.generate()
    a.to_csv("-".join([str(j) for j in [mechanism,'train', str(20)]]), index=False)