예제 #1
0
def run_CDT(alg, x, y, vis=True, verbose=False):
    if alg == 'PC':
        obj = PC()
    elif alg == 'SAM':
        obj = SAM()
    elif alg == 'CAM':
        obj = CAM()
    elif alg == 'GES':
        obj = GES()
    else:
        assert (False)
    obj.verbose = verbose
    output = obj.predict(x)

    # and well, I want to return: prec, recall, shd
    # or, I can just have the adjacency matrix, and compute the matrix myself
    #
    # FIXME the default order seems to be correct
    mat = nx.to_numpy_matrix(output)
    print('adjacency matrix:')
    print(mat)

    if vis:
        nx.draw_networkx(output)
        plt.show()

    return mat
예제 #2
0
def test_SAM():
    data, graph = load_dataset("sachs")
    obj = SAM()
    #The predict() method works without a graph, or with a
    #directed or undirected graph provided as an input
    #
    # (HEBI: this seems to be very slow, 6+ hours)
    output = obj.predict(data)  #No graph provided as an argument

    output = obj.predict(data, nx.Graph(graph))  #With an undirected graph

    output = obj.predict(data, graph)  #With a directed graph

    #To view the graph created, run the below commands:
    nx.draw_networkx(output, font_size=8)
    plt.show()
예제 #3
0
def test_SAM():
    m = SAM(train_epochs=10, test_epochs=10, nh=10, dnh=10, nruns=1, njobs=1)
    assert isinstance(m.predict(data_graph), nx.DiGraph)
    return 0