예제 #1
0
def pdfeat(g,
           fil='deg',
           dataset='wikipedia',
           radius=1,
           norm_flag=True,
           recomp=True):
    n2g = network2g(dataset=dataset,
                    fil=fil,
                    norm_flag='yes',
                    sub=True,
                    recomp=recomp)
    g = n2g.compute(g)
    n_node = len(g)

    ego = egograph(g,
                   radius=radius,
                   n=n_node,
                   recompute_flag=recomp,
                   norm_flag=norm_flag)
    ego.emb_file(dataset=dataset)
    egographs = ego.egographs(method='batch_parallel')
    dgms = alldgms(egographs,
                   radius=radius,
                   dataset=dataset,
                   recompute_flag=recomp,
                   method='serial',
                   n=n_node)  # can do parallel computing
    pdvector = pdemb(dgms, dataset, recompute_flag=True, norm=norm_flag)
    return pdvector
예제 #2
0
    lapdist = cdist(lapfeat, lapfeat, metric='euclidean')

    kwargs = {'h': 0.3}
    g = fil_strategy(g, lapfeat, method=fil_method, viz_flag=False, **kwargs)

    ego = egograph(g,
                   radius=radius,
                   n=len(g),
                   recompute_flag=True,
                   norm_flag=True,
                   print_flag=False)
    egographs = ego.egographs(method='serial')
    dgms = alldgms(egographs,
                   radius=radius,
                   dataset='',
                   recompute_flag=True,
                   method='serial',
                   n=n1 + n2,
                   zigzag=zigzag)  # compute dgms in parallel

    swdgms = dgms2swdgms(dgms)
    kwargs = {'bw': 1, 'n_directions': 10}
    sw_kernel, _ = sw_parallel(swdgms,
                               swdgms,
                               kernel_type='sw',
                               parallel_flag=True,
                               **kwargs)
    clf = classifier(np.zeros((n1 + n2, 10)),
                     labels,
                     method=None,
                     kernel=sw_kernel)
예제 #3
0
    # plt.show()
    # sys.exit()
    # plot node fv value
    # viz fv value
    # val = dict(nx.get_node_attributes(gs[i], 'fv')).values()
    # plt.plot(val)
    # plt.title('q: %s, i: %s'%(q, i))
    # plt.show()
    # sys.exit()

    print('Finish computing lapfeat')
    dgms = alldgms(gs,
                   radius=float('inf'),
                   dataset='',
                   recompute_flag=True,
                   method='serial',
                   n=2 * n,
                   zigzag=zigzag)  # compute dgms in parallel
    print('Finish computing dgms')
    swdgms = dgms2swdgms(dgms)

    feat_kwargs = {'n_directions': 10, 'bw': 1}
    sw_kernel, _ = sw_parallel(swdgms,
                               swdgms,
                               kernel_type='sw',
                               parallel_flag=True,
                               **feat_kwargs)
    clf = classifier(np.zeros((len(labels), 10)),
                     labels,
                     method=None,