Esempio n. 1
0
def getgraphs(aid):
    if aid == 'bursi':
        return list(gspan.gspan_to_eden("bursi.pos.gspan")), list(
            gspan.gspan_to_eden("bursi.neg.gspan"))
    download_active = curry(download)(active=True, stepsize=50)
    download_inactive = curry(download)(active=False, stepsize=50)
    active = pipe(aid, download_active, sdf_to_nx, list)
    inactive = pipe(aid, download_inactive, sdf_to_nx, list)
    return active, inactive
Esempio n. 2
0
def bursi_get_extremes(num=200):
    po, ne = list(gspan.gspan_to_eden("bursi.pos.gspan")), list(
        gspan.gspan_to_eden("bursi.neg.gspan"))
    X, y = graphs_to_Xy(po, ne)
    esti = SGDClassifier(average=True,
                         class_weight='balanced',
                         shuffle=True,
                         n_jobs=4,
                         loss='log')
    esti.fit(X, y)
    res = [(score, idd)
           for idd, score in enumerate(esti.decision_function(X))]  # list
    res.sort()
    graphs = po + ne
    # returns pos/neg
    return [graphs[idd] for (score, idd) in res[0 - num:]
            ], [graphs[idd] for (score, idd) in res[:num]]
        exit()

    print "*raw args"
    print "*" * 80
    print args

    # verbosity
    from eden.util import configure_logging
    import logging
    configure_logging(logging.getLogger(),verbosity=args['verbose'])
    args.pop('verbose')

    # graphs
    from eden.io.gspan import gspan_to_eden
    from itertools import islice
    args['graph_iter'] = islice(gspan_to_eden(args.pop('start_graphs')),args.pop('num_graphs'))


    #output
    OUTFILE=args.pop('out')
    MODEL=args.pop('model')

    # CREATE SAMPLER
    from graphlearn01.graphlearn import Sampler
    s=Sampler()
    s.load(MODEL)
    results=s.transform(**args)


    import graphlearn01.utils.draw_openbabel as ob
Esempio n. 4
0
        exit()

    print "*raw args"
    print "*" * 80
    print args

    # verbosity
    from eden.util import configure_logging
    import logging
    configure_logging(logging.getLogger(), verbosity=args['verbose'])
    args.pop('verbose')

    # graphs
    from eden.io.gspan import gspan_to_eden
    from itertools import islice
    args['graph_iter'] = islice(gspan_to_eden(args.pop('start_graphs')),
                                args.pop('num_graphs'))

    #output
    OUTFILE = args.pop('out')
    MODEL = args.pop('model')

    # CREATE SAMPLER
    from graphlearn01.graphlearn import Sampler
    s = Sampler()
    s.load(MODEL)
    results = s.transform(**args)

    import graphlearn01.utils.draw_openbabel as ob

    for i, samplepath in enumerate(results):
Esempio n. 5
0
    # estimator, if the user is providing a negative graph set, we use
    # the twoclass esti OO
    import graphlearn01.estimate as estimate
    if args['negative_input']==None:
        args['estimator']=estimate.OneClassEstimator(nu=.5, cv=2, n_jobs=-1)
    else:
        args['estimator']=estimate.TwoClassEstimator( cv=2, n_jobs=-1)
        
    #args for fitting:
    from eden.io.gspan import gspan_to_eden
    from itertools import islice
    fitargs={ k:args.pop(k) for k in ['lsgg_include_negatives','grammar_n_jobs','grammar_batch_size']}

    if args['negative_input']!=None:
        fitargs['negative_input'] = islice(gspan_to_eden(args.pop('negative_input')),args.pop('num_graphs_neg'))
    else:
        args.pop('negative_input')
        args.pop('num_graphs_neg')

    fitargs['input'] = islice(gspan_to_eden(args.pop('input')),args.pop('num_graphs'))

    #output
    OUTFILE=args.pop('output')

    print "*Sampler init"
    print "*"*80
    print args

    # CREATE SAMPLER, dumping the rest of the parsed args :) 
    from graphlearn01.graphlearn import Sampler
Esempio n. 6
0
def get_graphs(dataset_fname='../../toolsdata/bursi.pos.gspan', size=100):
    return list(islice(gspan_to_eden(dataset_fname), size))