circle abstraction for chemical structure graphs

In this notebook I show how to use Graphlearn with abstract graphs to generate molecules with an abstraction that deals with circular motives.

initialising


In [1]:
%load_ext autoreload
%autoreload 2
from eden.util import configure_logging
import logging
debug=True

configure_logging(logging.getLogger(),verbosity=1+debug)
%matplotlib inline


/home/ikea/.local/lib/python2.7/site-packages/sklearn/cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
  "This module will be removed in 0.20.", DeprecationWarning)
/home/ikea/.local/lib/python2.7/site-packages/sklearn/grid_search.py:43: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. This module will be removed in 0.20.
  DeprecationWarning)
/usr/lib/python2.7/dist-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
  warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')

get_graphs will provide data( networkx graphs )


In [2]:
from eden.io.gspan import gspan_to_eden
from itertools import islice

def get_graphs(dataset_fname='../../toolsdata/bursi.pos.gspan', size=100):
    return  islice(gspan_to_eden(dataset_fname),size)

I demonstrate what an abstract graph looks like


In [3]:
from graphlearn.utils import draw
import graphlearn.minor.molecule.transform_cycle as mole
import graphlearn.minor.decompose as decompose
from graphlearn.graphlearn import Sampler as GLS
from eden.graph import Vectorizer
vectorizer=Vectorizer()

# get a graph and prepare it
graphs=get_graphs()
g=graphs.next()
g=vectorizer._graph_preprocessing(g)



# why do we need a decomposer? we dont do decomp here..
#decomposer = decompose.MinorDecomposer(                                            
#                       include_base=False,
#                       base_thickness_list=[2])




#the preprocessor makes the abstraction, wrapper provides convenient format for drawing

preproc=mole.GraphTransformerCircles()

#graph_wrapper = decomposer.make_new_decomposer(g)

#graph=graph_wrapper.pre_vectorizer_graph(nested=True)
graph= preproc.abstract(g)

# draw 
draw.graphlearn(graph,size=10, abstract_color='red', contract=True,ignore_for_layout='nesting')


Here we see different views on a graph, provided by the wrapper,

for the sampling process CIPs need to be extracted. here we see this mechanism.


In [4]:
from graphlearn.utils import draw
from graphlearn.graphlearn import Sampler as GLS
from eden.graph import Vectorizer


import graphlearn.minor.molecule.transform_cycle as mole
import graphlearn.minor.decompose as decompose



transformer=mole.GraphTransformerCircles()
decomposer = decompose.MinorDecomposer()


print 'DEMONSTRATING WRAPPER'
graphs=get_graphs()

for i in range(1):
    print 'grammar example %d' % i
    g=graphs.next()
    
    
    print g.graph
    gm=decomposer.make_new_decomposer( transformer.transform([g])[0])
    
    draw.graphlearn([gm.pre_vectorizer_graph(nested=True), gm.abstract_graph(),gm.base_graph()], 
                    size = 15,
                    vertex_label = 'label',
                    contract=False)

    
print 'DEMONSTRATING EXTRACTION'  
radius_list=[0,2]
thickness_list=[2,4]
base_thickness_list=[2]
argz=(gm,radius_list,thickness_list,Vectorizer(),2**20-1,lambda x,y:True, base_thickness_list)

cips=gm.all_core_interface_pairs(thickness_list=[2],radius_list=[0,1])
draw.graphlearn(cips[0][0].graph, contract=False)
draw.graphlearn(cips[0][1].graph, contract=False)


DEMONSTRATING WRAPPER
grammar example 0
{'id': 't # id 1 target: 1\n'}
/home/ikea/.local/lib/python2.7/site-packages/pygraphviz/agraph.py:1338: RuntimeWarning: Warning: Max. iterations (5300) reached on graph %3

  warnings.warn(b"".join(errors), RuntimeWarning)
DEMONSTRATING EXTRACTION

here we prepare a sampler and then take a closer look at the generated grammar.


In [5]:
%%time
from graphlearn.graphlearn import Sampler as GLS
graphs = get_graphs(size=200)
sampler=GLS(#radius_list=[0,1],
            #thickness_list=[1], 
            #min_cip_count=2, 
            #min_interface_count=2, 
            decomposer=decomposer,
            graphtransformer=mole.GraphTransformerCircles())
sampler.fit(graphs)


accept_min_similarity: 0.0
accept_static_penalty: 0.0
batch_size: 10
    burnin: 0
core_choice_bytrial: False
core_choice_bytrial_multiplier: 1.0
decomposer: no graphs in decomposer
estimatorobject: <graphlearn.estimate.OneClassEstimator instance at 0x7f00bbb74758>
feasibility_checker: <graphlearn.feasibility.FeasibilityChecker instance at 0x7f00bbb74b48>
graph_transformer: <graphlearn.minor.molecule.transform_cycle.GraphTransformerCircles object at 0x7f00b99cc390>
improving_linear_start_absolute: 0
improving_linear_start_fraction: 0
improving_penalty_per_step: 0.02
improving_threshold_absolute: 50
improving_threshold_fraction: -1
include_seed: False
keep_duplicates: False
      lsgg: <graphlearn.localsubstitutablegraphgrammar.LocalSubstitutableGraphGrammar object at 0x7f00b9cf3690>
maxbacktrack: 0
   monitor: False
  monitors: []
    n_jobs: 0
 n_samples: None
   n_steps: 50
orig_cip_max_positives: 1
orig_cip_min_positives: 0
orig_cip_score_tricks: False
probabilistic_core_choice: True
proposal_probability: False
quick_skip_orig_cip: False
random_state: None
sampling_interval: 9999
score_core_choice: False
select_cip_max_tries: 20
similarity: -1
size_constrained_core_choice: -1
size_diff_core_filter: -1
vectorizer:               __version__: 1.0.1                   bitmask: 65535                block_size: 100                complexity: 3                         d: 3                  discrete: True              feature_size: 65537       inner_normalization: True                 key_class: class            key_importance: importance                 key_label: label               key_nesting: nesting                  key_svec: svec                   key_vec: vec                key_weight: weight                     min_d: 0                     min_r: 0                    n_jobs: 1                      name: Vectorizer                     nbits: 16             normalization: True                positional: False                         r: 3              weights_dict: None
#instances: 200  #interfaces: 82   #cores: 66   #core-interface-pairs: 314

Classifier:
SGDClassifier(alpha=0.000187567852834, average=False, class_weight=None,
       epsilon=0.1, eta0=0.363636782851, fit_intercept=True, l1_ratio=0.15,
       learning_rate='optimal', loss='log', n_iter=82, n_jobs=1,
       penalty='l1', power_t=0.299025634434, random_state=None,
       shuffle=True, verbose=0, warm_start=False)

Predictive performance:
            accuracy: 1.000 +- 0.000
           precision: 1.000 +- 0.000
              recall: 1.000 +- 0.000
                  f1: 1.000 +- 0.000
   average_precision: 1.000 +- 0.000
             roc_auc: 1.000 +- 0.000
CPU times: user 9.25 s, sys: 800 ms, total: 10 s
Wall time: 20.9 s

In [6]:
#show congruent cips in grammar
draw.draw_grammar(sampler.lsgg.productions,n_productions=5,n_graphs_per_production=5,
                     n_graphs_per_line=5, size=9, contract=False,
                     colormap='Paired', invert_colormap=False,
                     vertex_alpha=0.6, edge_alpha=0.5,  abstract_interface=True)


interface id: 8188 [23 options]
interface id: 610744 [16 options]
interface id: 555600 [15 options]
interface id: 161292 [15 options]
interface id: 735276 [14 options]

Molecule sampling


In [7]:
%%time
import graphlearn.utils.draw as draw
import itertools

# parameters
graphs = get_graphs()
id_start=15
id_end=id_start+9
graphs = itertools.islice(graphs,id_start,id_end)
n_steps=100


#sampling
graphs = sampler.transform(graphs)

 
scores=[]
ids=range(id_start,id_end)
for i,path_graphs in enumerate(graphs):
    # path_graphs is a list of 'sampled' graphs for 1 run 
    print 'Graph id: %d'%(ids[i])
    #save score
    scores.append(sampler.monitors[i].sampling_info['score_history'])
    # draw
    draw.graphlearn(path_graphs,
                           n_graphs_per_line=5, size=10, 
                           colormap='Paired', invert_colormap=False, vertex_color='color_level',
                           vertex_alpha=0.5, edge_alpha=0.7,edge_label='label'  )


preprocessing grammar
_propose_graph: iteration 0 ; core 0 of 15 ; original_cips tried  0 ; size 45
propose failed.. usualy the problem is propose_single_cip
Traceback (most recent call last):
  File "/home/ikea/GRAPHLEARN/GraphLearn/graphlearn/graphlearn.py", line 582, in transform_single
    candidate_graph_decomposer = self._propose(graph_decomposer)
  File "/home/ikea/GRAPHLEARN/GraphLearn/graphlearn/graphlearn.py", line 837, in _propose
    raise Exception("propose failed.. usualy the problem is propose_single_cip")
Exception: propose failed.. usualy the problem is propose_single_cip

_sample stopped at 1 out of 50 n_steps
Graph id: 15
propose failed.. usualy the problem is propose_single_cip
Traceback (most recent call last):
  File "/home/ikea/GRAPHLEARN/GraphLearn/graphlearn/graphlearn.py", line 582, in transform_single
    candidate_graph_decomposer = self._propose(graph_decomposer)
  File "/home/ikea/GRAPHLEARN/GraphLearn/graphlearn/graphlearn.py", line 837, in _propose
    raise Exception("propose failed.. usualy the problem is propose_single_cip")
Exception: propose failed.. usualy the problem is propose_single_cip

_sample stopped at 0 out of 50 n_steps
Graph id: 16
_propose_graph: iteration 0 ; core 0 of 15 ; original_cips tried  0 ; size 35
_propose_graph: iteration 1 ; core 0 of 1 ; original_cips tried  0 ; size 20
_propose_graph: iteration 2 ; core 0 of 15 ; original_cips tried  0 ; size 20
_propose_graph: iteration 3 ; core 0 of 15 ; original_cips tried  0 ; size 20
_propose_graph: iteration 4 ; core 0 of 6 ; original_cips tried  0 ; size 33
_propose_graph: iteration 5 ; core 0 of 15 ; original_cips tried  0 ; size 33
_propose_graph: iteration 6 ; core 0 of 15 ; original_cips tried  0 ; size 33
_propose_graph: iteration 7 ; core 0 of 15 ; original_cips tried  0 ; size 33
_propose_graph: iteration 8 ; core 0 of 15 ; original_cips tried  0 ; size 33
_propose_graph: iteration 9 ; core 0 of 13 ; original_cips tried  0 ; size 35
_propose_graph: iteration 10 ; core 0 of 5 ; original_cips tried  0 ; size 35
_propose_graph: iteration 11 ; core 0 of 15 ; original_cips tried  0 ; size 35
_propose_graph: iteration 12 ; core 0 of 15 ; original_cips tried  0 ; size 35
_propose_graph: iteration 13 ; core 0 of 3 ; original_cips tried  0 ; size 35
_propose_graph: iteration 14 ; core 0 of 3 ; original_cips tried  0 ; size 52
_propose_graph: iteration 15 ; core 0 of 3 ; original_cips tried  0 ; size 54
_propose_graph: iteration 16 ; core 0 of 3 ; original_cips tried  0 ; size 54
_propose_graph: iteration 17 ; core 0 of 2 ; original_cips tried  0 ; size 52
_propose_graph: iteration 18 ; core 0 of 1 ; original_cips tried  0 ; size 52
_propose_graph: iteration 19 ; core 0 of 3 ; original_cips tried  0 ; size 52
_propose_graph: iteration 20 ; core 0 of 1 ; original_cips tried  0 ; size 35
_propose_graph: iteration 21 ; core 0 of 15 ; original_cips tried  0 ; size 35
_propose_graph: iteration 22 ; core 0 of 1 ; original_cips tried  0 ; size 35
_propose_graph: iteration 23 ; core 0 of 5 ; original_cips tried  0 ; size 35
_propose_graph: iteration 24 ; core 0 of 1 ; original_cips tried  0 ; size 35
_propose_graph: iteration 25 ; core 0 of 1 ; original_cips tried  0 ; size 20
_propose_graph: iteration 26 ; core 0 of 5 ; original_cips tried  0 ; size 20
_propose_graph: iteration 27 ; core 0 of 22 ; original_cips tried  0 ; size 18
_propose_graph: iteration 28 ; core 0 of 15 ; original_cips tried  0 ; size 18
_propose_graph: iteration 29 ; core 0 of 5 ; original_cips tried  0 ; size 18
_propose_graph: iteration 30 ; core 0 of 3 ; original_cips tried  0 ; size 18
_propose_graph: iteration 31 ; core 0 of 22 ; original_cips tried  0 ; size 18
_propose_graph: iteration 32 ; core 0 of 3 ; original_cips tried  0 ; size 18
_propose_graph: iteration 33 ; core 0 of 1 ; original_cips tried  0 ; size 20
_propose_graph: iteration 34 ; core 0 of 22 ; original_cips tried  0 ; size 20
_propose_graph: iteration 35 ; core 0 of 3 ; original_cips tried  0 ; size 20
_propose_graph: iteration 36 ; core 0 of 11 ; original_cips tried  0 ; size 20
_propose_graph: iteration 37 ; core 0 of 22 ; original_cips tried  0 ; size 20
_propose_graph: iteration 38 ; core 0 of 5 ; original_cips tried  0 ; size 20
_propose_graph: iteration 39 ; core 0 of 11 ; original_cips tried  0 ; size 22
_propose_graph: iteration 40 ; core 0 of 1 ; original_cips tried  0 ; size 22
_propose_graph: iteration 41 ; core 0 of 4 ; original_cips tried  0 ; size 22
_propose_graph: iteration 42 ; core 0 of 2 ; original_cips tried  0 ; size 22
_propose_graph: iteration 43 ; core 0 of 1 ; original_cips tried  0 ; size 22
_propose_graph: iteration 44 ; core 0 of 2 ; original_cips tried  0 ; size 22
_propose_graph: iteration 45 ; core 0 of 22 ; original_cips tried  0 ; size 22
_propose_graph: iteration 46 ; core 0 of 5 ; original_cips tried  0 ; size 22
_propose_graph: iteration 47 ; core 0 of 22 ; original_cips tried  0 ; size 22
_propose_graph: iteration 48 ; core 0 of 3 ; original_cips tried  0 ; size 22
_propose_graph: iteration 49 ; core 0 of 22 ; original_cips tried  0 ; size 24
Graph id: 17
_propose_graph: iteration 0 ; core 0 of 15 ; original_cips tried  0 ; size 35
_propose_graph: iteration 1 ; core 0 of 15 ; original_cips tried  0 ; size 41
_propose_graph: iteration 2 ; core 0 of 5 ; original_cips tried  0 ; size 37
_propose_graph: iteration 3 ; core 0 of 15 ; original_cips tried  0 ; size 37
_propose_graph: iteration 4 ; core 0 of 1 ; original_cips tried  0 ; size 41
_propose_graph: iteration 5 ; core 0 of 2 ; original_cips tried  0 ; size 56
_propose_graph: iteration 6 ; core 0 of 3 ; original_cips tried  0 ; size 56
_propose_graph: iteration 7 ; core 0 of 5 ; original_cips tried  0 ; size 56
_propose_graph: iteration 8 ; core 0 of 6 ; original_cips tried  0 ; size 56
_propose_graph: iteration 9 ; core 0 of 1 ; original_cips tried  0 ; size 56
_propose_graph: iteration 10 ; core 0 of 1 ; original_cips tried  0 ; size 45
_propose_graph: iteration 11 ; core 0 of 22 ; original_cips tried  0 ; size 30
_propose_graph: iteration 12 ; core 0 of 15 ; original_cips tried  0 ; size 30
_propose_graph: iteration 13 ; core 0 of 2 ; original_cips tried  0 ; size 24
_propose_graph: iteration 14 ; core 0 of 14 ; original_cips tried  0 ; size 24
_propose_graph: iteration 15 ; core 0 of 1 ; original_cips tried  0 ; size 24
propose failed.. usualy the problem is propose_single_cip
Traceback (most recent call last):
  File "/home/ikea/GRAPHLEARN/GraphLearn/graphlearn/graphlearn.py", line 582, in transform_single
    candidate_graph_decomposer = self._propose(graph_decomposer)
  File "/home/ikea/GRAPHLEARN/GraphLearn/graphlearn/graphlearn.py", line 837, in _propose
    raise Exception("propose failed.. usualy the problem is propose_single_cip")
Exception: propose failed.. usualy the problem is propose_single_cip

_sample stopped at 16 out of 50 n_steps
Graph id: 18
_propose_graph: iteration 0 ; core 0 of 3 ; original_cips tried  0 ; size 32
_propose_graph: iteration 1 ; core 0 of 3 ; original_cips tried  0 ; size 34
_propose_graph: iteration 2 ; core 0 of 2 ; original_cips tried  0 ; size 32
_propose_graph: iteration 3 ; core 0 of 1 ; original_cips tried  0 ; size 34
_propose_graph: iteration 4 ; core 0 of 1 ; original_cips tried  0 ; size 38
_propose_graph: iteration 5 ; core 0 of 13 ; original_cips tried  0 ; size 40
_propose_graph: iteration 6 ; core 0 of 22 ; original_cips tried  0 ; size 42
_propose_graph: iteration 7 ; core 0 of 4 ; original_cips tried  0 ; size 42
_propose_graph: iteration 8 ; core 0 of 1 ; original_cips tried  0 ; size 42
propose failed.. usualy the problem is propose_single_cip
Traceback (most recent call last):
  File "/home/ikea/GRAPHLEARN/GraphLearn/graphlearn/graphlearn.py", line 582, in transform_single
    candidate_graph_decomposer = self._propose(graph_decomposer)
  File "/home/ikea/GRAPHLEARN/GraphLearn/graphlearn/graphlearn.py", line 837, in _propose
    raise Exception("propose failed.. usualy the problem is propose_single_cip")
Exception: propose failed.. usualy the problem is propose_single_cip

_sample stopped at 9 out of 50 n_steps
Graph id: 19
_propose_graph: iteration 0 ; core 0 of 2 ; original_cips tried  0 ; size 83
_propose_graph: iteration 1 ; core 0 of 1 ; original_cips tried  0 ; size 85
_propose_graph: iteration 2 ; core 0 of 1 ; original_cips tried  0 ; size 87
_propose_graph: iteration 3 ; core 0 of 1 ; original_cips tried  0 ; size 85
_propose_graph: iteration 4 ; core 0 of 3 ; original_cips tried  0 ; size 102
_propose_graph: iteration 5 ; core 0 of 1 ; original_cips tried  0 ; size 85
_propose_graph: iteration 6 ; core 0 of 3 ; original_cips tried  0 ; size 83
_propose_graph: iteration 7 ; core 0 of 3 ; original_cips tried  0 ; size 100
_propose_graph: iteration 8 ; core 0 of 3 ; original_cips tried  0 ; size 100
_propose_graph: iteration 9 ; core 0 of 15 ; original_cips tried  0 ; size 100
_propose_graph: iteration 10 ; core 0 of 15 ; original_cips tried  0 ; size 100
_propose_graph: iteration 11 ; core 0 of 15 ; original_cips tried  0 ; size 100
_propose_graph: iteration 12 ; core 0 of 1 ; original_cips tried  0 ; size 100
_propose_graph: iteration 13 ; core 0 of 4 ; original_cips tried  0 ; size 102
_propose_graph: iteration 14 ; core 0 of 3 ; original_cips tried  0 ; size 102
_propose_graph: iteration 15 ; core 0 of 2 ; original_cips tried  0 ; size 104
_propose_graph: iteration 16 ; core 0 of 15 ; original_cips tried  0 ; size 102
_propose_graph: iteration 17 ; core 0 of 2 ; original_cips tried  0 ; size 98
_propose_graph: iteration 18 ; core 0 of 2 ; original_cips tried  0 ; size 100
_propose_graph: iteration 19 ; core 0 of 15 ; original_cips tried  0 ; size 100
_propose_graph: iteration 20 ; core 0 of 15 ; original_cips tried  0 ; size 100
_propose_graph: iteration 21 ; core 0 of 15 ; original_cips tried  0 ; size 100
_propose_graph: iteration 22 ; core 0 of 15 ; original_cips tried  0 ; size 100
_propose_graph: iteration 23 ; core 0 of 2 ; original_cips tried  0 ; size 98
_propose_graph: iteration 24 ; core 0 of 1 ; original_cips tried  0 ; size 98
_propose_graph: iteration 25 ; core 0 of 1 ; original_cips tried  0 ; size 96
_propose_graph: iteration 26 ; core 0 of 15 ; original_cips tried  0 ; size 98
_propose_graph: iteration 27 ; core 0 of 15 ; original_cips tried  0 ; size 98
_propose_graph: iteration 28 ; core 0 of 1 ; original_cips tried  0 ; size 98
_propose_graph: iteration 29 ; core 0 of 2 ; original_cips tried  0 ; size 96
_propose_graph: iteration 30 ; core 0 of 2 ; original_cips tried  0 ; size 90
_propose_graph: iteration 31 ; core 0 of 3 ; original_cips tried  0 ; size 88
_propose_graph: iteration 32 ; core 0 of 4 ; original_cips tried  0 ; size 105
_propose_graph: iteration 33 ; core 0 of 2 ; original_cips tried  0 ; size 105
_propose_graph: iteration 34 ; core 0 of 2 ; original_cips tried  0 ; size 105
_propose_graph: iteration 35 ; core 0 of 14 ; original_cips tried  0 ; size 105
_propose_graph: iteration 36 ; core 0 of 3 ; original_cips tried  0 ; size 109
_propose_graph: iteration 37 ; core 0 of 15 ; original_cips tried  0 ; size 109
_propose_graph: iteration 38 ; core 0 of 3 ; original_cips tried  0 ; size 111
_propose_graph: iteration 39 ; core 0 of 5 ; original_cips tried  0 ; size 120
_propose_graph: iteration 40 ; core 0 of 3 ; original_cips tried  0 ; size 122
_propose_graph: iteration 41 ; core 0 of 4 ; original_cips tried  0 ; size 122
_propose_graph: iteration 42 ; core 0 of 4 ; original_cips tried  0 ; size 126
_propose_graph: iteration 43 ; core 0 of 2 ; original_cips tried  0 ; size 126
_propose_graph: iteration 44 ; core 0 of 5 ; original_cips tried  0 ; size 126
_propose_graph: iteration 45 ; core 0 of 15 ; original_cips tried  0 ; size 124
_propose_graph: iteration 46 ; core 0 of 1 ; original_cips tried  0 ; size 124
_propose_graph: iteration 47 ; core 0 of 1 ; original_cips tried  0 ; size 124
_propose_graph: iteration 48 ; core 0 of 15 ; original_cips tried  0 ; size 124
_propose_graph: iteration 49 ; core 0 of 1 ; original_cips tried  0 ; size 155
Graph id: 20
_propose_graph: iteration 0 ; core 0 of 3 ; original_cips tried  0 ; size 37
_propose_graph: iteration 1 ; core 0 of 3 ; original_cips tried  0 ; size 22
_propose_graph: iteration 2 ; core 0 of 3 ; original_cips tried  0 ; size 24
_propose_graph: iteration 3 ; core 0 of 14 ; original_cips tried  0 ; size 22
_propose_graph: iteration 4 ; core 0 of 5 ; original_cips tried  0 ; size 33
_propose_graph: iteration 5 ; core 0 of 14 ; original_cips tried  0 ; size 20
_propose_graph: iteration 6 ; core 0 of 14 ; original_cips tried  0 ; size 31
_propose_graph: iteration 7 ; core 0 of 3 ; original_cips tried  0 ; size 31
_propose_graph: iteration 8 ; core 0 of 3 ; original_cips tried  0 ; size 33
_propose_graph: iteration 9 ; core 0 of 14 ; original_cips tried  0 ; size 31
_propose_graph: iteration 10 ; core 0 of 5 ; original_cips tried  0 ; size 31
_propose_graph: iteration 11 ; core 0 of 1 ; original_cips tried  0 ; size 33
_propose_graph: iteration 12 ; core 0 of 3 ; original_cips tried  0 ; size 37
_propose_graph: iteration 13 ; core 0 of 15 ; original_cips tried  0 ; size 48
_propose_graph: iteration 14 ; core 0 of 22 ; original_cips tried  0 ; size 35
_propose_graph: iteration 15 ; core 0 of 5 ; original_cips tried  0 ; size 22
_propose_graph: iteration 16 ; core 0 of 1 ; original_cips tried  0 ; size 22
_propose_graph: iteration 17 ; core 0 of 5 ; original_cips tried  0 ; size 22
_propose_graph: iteration 18 ; core 0 of 14 ; original_cips tried  0 ; size 18
_propose_graph: iteration 19 ; core 0 of 14 ; original_cips tried  0 ; size 14
_propose_graph: iteration 20 ; core 0 of 1 ; original_cips tried  0 ; size 29
_propose_graph: iteration 21 ; core 0 of 1 ; original_cips tried  0 ; size 29
_propose_graph: iteration 22 ; core 0 of 1 ; original_cips tried  0 ; size 29
_propose_graph: iteration 23 ; core 0 of 15 ; original_cips tried  0 ; size 29
_propose_graph: iteration 24 ; core 0 of 15 ; original_cips tried  0 ; size 29
_propose_graph: iteration 25 ; core 0 of 1 ; original_cips tried  0 ; size 29
_propose_graph: iteration 26 ; core 0 of 3 ; original_cips tried  0 ; size 18
_propose_graph: iteration 27 ; core 0 of 5 ; original_cips tried  0 ; size 18
_propose_graph: iteration 28 ; core 0 of 22 ; original_cips tried  0 ; size 18
_propose_graph: iteration 29 ; core 0 of 3 ; original_cips tried  0 ; size 20
_propose_graph: iteration 30 ; core 0 of 14 ; original_cips tried  0 ; size 20
_propose_graph: iteration 31 ; core 0 of 5 ; original_cips tried  0 ; size 31
_propose_graph: iteration 32 ; core 0 of 5 ; original_cips tried  0 ; size 31
_propose_graph: iteration 33 ; core 0 of 2 ; original_cips tried  0 ; size 31
_propose_graph: iteration 34 ; core 0 of 1 ; original_cips tried  0 ; size 33
_propose_graph: iteration 35 ; core 0 of 3 ; original_cips tried  0 ; size 33
_propose_graph: iteration 36 ; core 0 of 5 ; original_cips tried  0 ; size 33
_propose_graph: iteration 37 ; core 0 of 3 ; original_cips tried  0 ; size 33
_propose_graph: iteration 38 ; core 0 of 2 ; original_cips tried  0 ; size 29
_propose_graph: iteration 39 ; core 0 of 15 ; original_cips tried  0 ; size 29
_propose_graph: iteration 40 ; core 0 of 15 ; original_cips tried  0 ; size 29
_propose_graph: iteration 41 ; core 0 of 22 ; original_cips tried  0 ; size 29
_propose_graph: iteration 42 ; core 0 of 2 ; original_cips tried  0 ; size 29
_propose_graph: iteration 43 ; core 0 of 15 ; original_cips tried  0 ; size 29
_propose_graph: iteration 44 ; core 0 of 14 ; original_cips tried  0 ; size 29
_propose_graph: iteration 45 ; core 0 of 1 ; original_cips tried  0 ; size 29
_propose_graph: iteration 46 ; core 0 of 15 ; original_cips tried  0 ; size 29
_propose_graph: iteration 47 ; core 0 of 15 ; original_cips tried  0 ; size 29
_propose_graph: iteration 48 ; core 0 of 2 ; original_cips tried  0 ; size 29
_propose_graph: iteration 49 ; core 0 of 15 ; original_cips tried  0 ; size 29
Graph id: 21
_propose_graph: iteration 0 ; core 0 of 3 ; original_cips tried  0 ; size 32
_propose_graph: iteration 1 ; core 0 of 22 ; original_cips tried  0 ; size 40
_propose_graph: iteration 2 ; core 0 of 1 ; original_cips tried  0 ; size 40
_propose_graph: iteration 3 ; core 0 of 4 ; original_cips tried  0 ; size 40
_propose_graph: iteration 4 ; core 0 of 5 ; original_cips tried  0 ; size 51
_propose_graph: iteration 5 ; core 0 of 22 ; original_cips tried  0 ; size 49
_propose_graph: iteration 6 ; core 0 of 5 ; original_cips tried  0 ; size 49
_propose_graph: iteration 7 ; core 0 of 5 ; original_cips tried  0 ; size 51
_propose_graph: iteration 8 ; core 0 of 22 ; original_cips tried  0 ; size 51
_propose_graph: iteration 9 ; core 0 of 14 ; original_cips tried  0 ; size 51
_propose_graph: iteration 10 ; core 0 of 5 ; original_cips tried  0 ; size 51
_propose_graph: iteration 11 ; core 0 of 1 ; original_cips tried  0 ; size 51
_propose_graph: iteration 12 ; core 0 of 22 ; original_cips tried  0 ; size 55
_propose_graph: iteration 13 ; core 0 of 1 ; original_cips tried  0 ; size 72
_propose_graph: iteration 14 ; core 0 of 4 ; original_cips tried  0 ; size 76
_propose_graph: iteration 15 ; core 0 of 14 ; original_cips tried  0 ; size 76
_propose_graph: iteration 16 ; core 0 of 4 ; original_cips tried  0 ; size 63
_propose_graph: iteration 17 ; core 0 of 2 ; original_cips tried  0 ; size 61
_propose_graph: iteration 18 ; core 0 of 14 ; original_cips tried  0 ; size 59
_propose_graph: iteration 19 ; core 0 of 14 ; original_cips tried  0 ; size 59
_propose_graph: iteration 20 ; core 0 of 3 ; original_cips tried  0 ; size 59
_propose_graph: iteration 21 ; core 0 of 4 ; original_cips tried  0 ; size 76
_propose_graph: iteration 22 ; core 0 of 5 ; original_cips tried  0 ; size 80
_propose_graph: iteration 23 ; core 0 of 3 ; original_cips tried  0 ; size 80
_propose_graph: iteration 24 ; core 0 of 3 ; original_cips tried  0 ; size 80
_propose_graph: iteration 25 ; core 0 of 22 ; original_cips tried  0 ; size 80
_propose_graph: iteration 26 ; core 0 of 14 ; original_cips tried  0 ; size 91
_propose_graph: iteration 27 ; core 0 of 13 ; original_cips tried  0 ; size 91
_propose_graph: iteration 28 ; core 0 of 4 ; original_cips tried  0 ; size 89
_propose_graph: iteration 29 ; core 0 of 22 ; original_cips tried  0 ; size 89
_propose_graph: iteration 30 ; core 0 of 22 ; original_cips tried  0 ; size 100
_propose_graph: iteration 31 ; core 0 of 4 ; original_cips tried  0 ; size 100
_propose_graph: iteration 32 ; core 0 of 1 ; original_cips tried  0 ; size 100
_propose_graph: iteration 33 ; core 0 of 14 ; original_cips tried  0 ; size 100
_propose_graph: iteration 34 ; core 0 of 4 ; original_cips tried  0 ; size 98
_propose_graph: iteration 35 ; core 0 of 3 ; original_cips tried  0 ; size 100
_propose_graph: iteration 36 ; core 0 of 4 ; original_cips tried  0 ; size 100
_propose_graph: iteration 37 ; core 0 of 1 ; original_cips tried  0 ; size 100
_propose_graph: iteration 38 ; core 0 of 3 ; original_cips tried  0 ; size 100
_propose_graph: iteration 39 ; core 0 of 15 ; original_cips tried  0 ; size 109
_propose_graph: iteration 40 ; core 0 of 3 ; original_cips tried  0 ; size 98
_propose_graph: iteration 41 ; core 0 of 14 ; original_cips tried  0 ; size 83
_propose_graph: iteration 42 ; core 0 of 14 ; original_cips tried  0 ; size 83
_propose_graph: iteration 43 ; core 0 of 11 ; original_cips tried  0 ; size 83
_propose_graph: iteration 44 ; core 0 of 15 ; original_cips tried  0 ; size 83
_propose_graph: iteration 45 ; core 0 of 1 ; original_cips tried  0 ; size 83
_propose_graph: iteration 46 ; core 0 of 3 ; original_cips tried  0 ; size 83
_propose_graph: iteration 47 ; core 0 of 22 ; original_cips tried  0 ; size 83
_propose_graph: iteration 48 ; core 0 of 4 ; original_cips tried  0 ; size 79
_propose_graph: iteration 49 ; core 0 of 22 ; original_cips tried  0 ; size 79
Graph id: 22
_propose_graph: iteration 0 ; core 0 of 22 ; original_cips tried  0 ; size 20
_propose_graph: iteration 1 ; core 0 of 3 ; original_cips tried  0 ; size 5
_propose_graph: iteration 2 ; core 0 of 22 ; original_cips tried  0 ; size 3
_propose_graph: iteration 3 ; core 0 of 22 ; original_cips tried  0 ; size 3
_propose_graph: iteration 4 ; core 0 of 22 ; original_cips tried  0 ; size 5
_propose_graph: iteration 5 ; core 0 of 22 ; original_cips tried  0 ; size 20
_propose_graph: iteration 6 ; core 0 of 14 ; original_cips tried  0 ; size 11
_propose_graph: iteration 7 ; core 0 of 13 ; original_cips tried  0 ; size 11
_propose_graph: iteration 8 ; core 0 of 11 ; original_cips tried  0 ; size 22
_propose_graph: iteration 9 ; core 0 of 14 ; original_cips tried  0 ; size 22
_propose_graph: iteration 10 ; core 0 of 13 ; original_cips tried  0 ; size 22
_propose_graph: iteration 11 ; core 0 of 5 ; original_cips tried  0 ; size 22
_propose_graph: iteration 12 ; core 0 of 4 ; original_cips tried  0 ; size 33
_propose_graph: iteration 13 ; core 0 of 14 ; original_cips tried  0 ; size 26
_propose_graph: iteration 14 ; core 0 of 11 ; original_cips tried  0 ; size 24
_propose_graph: iteration 15 ; core 0 of 14 ; original_cips tried  0 ; size 24
_propose_graph: iteration 16 ; core 0 of 4 ; original_cips tried  0 ; size 28
_propose_graph: iteration 17 ; core 0 of 14 ; original_cips tried  0 ; size 24
_propose_graph: iteration 18 ; core 0 of 1 ; original_cips tried  0 ; size 24
_propose_graph: iteration 19 ; core 0 of 22 ; original_cips tried  0 ; size 20
_propose_graph: iteration 20 ; core 0 of 4 ; original_cips tried  0 ; size 20
_propose_graph: iteration 21 ; core 0 of 14 ; original_cips tried  0 ; size 20
_propose_graph: iteration 22 ; core 0 of 22 ; original_cips tried  0 ; size 20
_propose_graph: iteration 23 ; core 0 of 14 ; original_cips tried  0 ; size 20
_propose_graph: iteration 24 ; core 0 of 11 ; original_cips tried  0 ; size 20
_propose_graph: iteration 25 ; core 0 of 4 ; original_cips tried  0 ; size 20
_propose_graph: iteration 26 ; core 0 of 3 ; original_cips tried  0 ; size 20
_propose_graph: iteration 27 ; core 0 of 22 ; original_cips tried  0 ; size 22
_propose_graph: iteration 28 ; core 0 of 3 ; original_cips tried  0 ; size 24
_propose_graph: iteration 29 ; core 0 of 3 ; original_cips tried  0 ; size 24
_propose_graph: iteration 30 ; core 0 of 22 ; original_cips tried  0 ; size 24
_propose_graph: iteration 31 ; core 0 of 22 ; original_cips tried  0 ; size 24
_propose_graph: iteration 32 ; core 0 of 22 ; original_cips tried  0 ; size 24
_propose_graph: iteration 33 ; core 0 of 22 ; original_cips tried  0 ; size 24
_propose_graph: iteration 34 ; core 0 of 4 ; original_cips tried  0 ; size 24
_propose_graph: iteration 35 ; core 0 of 11 ; original_cips tried  0 ; size 24
_propose_graph: iteration 36 ; core 0 of 22 ; original_cips tried  0 ; size 24
_propose_graph: iteration 37 ; core 0 of 3 ; original_cips tried  0 ; size 24
_propose_graph: iteration 38 ; core 0 of 3 ; original_cips tried  0 ; size 24
_propose_graph: iteration 39 ; core 0 of 14 ; original_cips tried  0 ; size 24
_propose_graph: iteration 40 ; core 0 of 22 ; original_cips tried  0 ; size 24
_propose_graph: iteration 41 ; core 0 of 4 ; original_cips tried  0 ; size 26
_propose_graph: iteration 42 ; core 0 of 1 ; original_cips tried  0 ; size 26
_propose_graph: iteration 43 ; core 0 of 1 ; original_cips tried  0 ; size 26
_propose_graph: iteration 44 ; core 0 of 4 ; original_cips tried  0 ; size 26
_propose_graph: iteration 45 ; core 0 of 22 ; original_cips tried  0 ; size 26
_propose_graph: iteration 46 ; core 0 of 14 ; original_cips tried  0 ; size 26
_propose_graph: iteration 47 ; core 0 of 22 ; original_cips tried  0 ; size 26
_propose_graph: iteration 48 ; core 0 of 3 ; original_cips tried  0 ; size 26
_propose_graph: iteration 49 ; core 0 of 22 ; original_cips tried  0 ; size 22
Graph id: 23
CPU times: user 15.5 s, sys: 4.3 s, total: 19.8 s
Wall time: 15.4 s

show score history for each samplerun


In [8]:
%matplotlib inline
from itertools import islice
import numpy as np
import matplotlib.pyplot as plt
step=1
num_graphs_per_plot=3
num_plots=np.ceil([len(scores)/num_graphs_per_plot])
for i in range(num_plots):
    plt.figure(figsize=(10,5))
    for j,score in enumerate(scores[i*num_graphs_per_plot:i*num_graphs_per_plot+num_graphs_per_plot]):
        data = list(islice(score,None, None, step))
        plt.plot(data, label='graph %d'%(j+i*num_graphs_per_plot+id_start))
    plt.legend(loc='lower right')
    plt.grid()
    plt.ylim(-0.1,1.1)
    plt.show()




In [9]:



/home/ikea/GRAPHLEARN/GraphLearn_examples/notebooks/Abstract

In [ ]: