In [1]:
%load_ext autoreload
%autoreload 2
%matplotlib inline
In [3]:
from __future__ import division
import numpy as np
import pandas as pd
from IPython.display import Image, display
import cana
from cana.datasets.bools import *
from cana.drawing.canalizing_map import draw_canalizing_map_graphviz
In [4]:
n = OR()
print( n)
print( 'k_r: %.2f - %.2f' % (n.input_redundancy(mode='node',bound='upper',norm=False), n.input_redundancy(mode='node',bound='lower',norm=False)))
print( 'k_e: %.2f - %.2f' % (n.effective_connectivity(mode='node',bound='upper',norm=False), n.effective_connectivity(mode='node',bound='lower',norm=False)))
print( 'k_s: %.2f - %.2f' % (n.input_symmetry(mode='node',bound='upper',norm=False), n.input_symmetry(mode='node',bound='lower',norm=False)))
print()
print( 'k_r: %s (upper)' % n.input_redundancy(mode='input',bound='upper'))
print( 'k_e: %s (upper)' % n.input_redundancy(mode='input',bound='upper'))
print()
dfLUT, dfPI, dfTS = n.look_up_table(), n.schemata_look_up_table(type='pi'), n.schemata_look_up_table(type='ts')
display(pd.concat({'Original LUT':dfLUT,'PI Schema':dfPI,'TS Schema':dfTS}, axis=1).fillna('-'))
draw_canalizing_map_graphviz(n.canalizing_map())
Out[4]:
In [5]:
n = CONTRADICTION()
n.name = 'Con'
print( n)
print( 'k_r: %.2f - %.2f' % (n.input_redundancy(mode='node',bound='upper',norm=False), n.input_redundancy(mode='node',bound='lower',norm=False)))
print( 'k_e: %.2f - %.2f' % (n.effective_connectivity(mode='node',bound='upper',norm=False), n.effective_connectivity(mode='node',bound='lower',norm=False)))
print( 'k_s: %.2f - %.2f' % (n.input_symmetry(mode='node',bound='upper',norm=False), n.input_symmetry(mode='node',bound='lower',norm=False)))
print()
print( 'k_r: %s (upper)' % n.input_redundancy(mode='input',bound='upper'))
print( 'k_e: %s (upper)' % n.input_redundancy(mode='input',bound='upper'))
print
dfLUT, dfPI, dfTS = n.look_up_table(), n.schemata_look_up_table(type='pi'), n.schemata_look_up_table(type='ts')
display(pd.concat({'Original LUT':dfLUT,'PI Schema':dfPI,'TS Schema':dfTS}, axis=1).fillna('-'))
draw_canalizing_map_graphviz(n.canalizing_map())
Out[5]:
In [6]:
n = XOR()
print( n)
print( 'k_r: %.2f - %.2f' % (n.input_redundancy(mode='node',bound='upper',norm=False), n.input_redundancy(mode='node',bound='lower',norm=False)))
print( 'k_e: %.2f - %.2f' % (n.effective_connectivity(mode='node',bound='upper',norm=False), n.effective_connectivity(mode='node',bound='lower',norm=False)))
print( 'k_s: %.2f - %.2f' % (n.input_symmetry(mode='node',bound='upper',norm=False), n.input_symmetry(mode='node',bound='lower',norm=False)))
print()
print( 'k_r: %s (upper)' % n.input_redundancy(mode='input',bound='upper'))
print( 'k_e: %s (upper)' % n.input_redundancy(mode='input',bound='upper'))
print
for input in [0,1]:
for ts,per,sms in n._two_symbols[input]:
print( 'TS: %s | PermIdx: %s | SameIdx: %s' % (ts, per,sms))
dfLUT, dfPI, dfTS = n.look_up_table(), n.schemata_look_up_table(type='pi'), n.schemata_look_up_table(type='ts')
display(pd.concat({'Original LUT':dfLUT,'PI Schema':dfPI,'TS Schema':dfTS}, axis=1).fillna('-'))
draw_canalizing_map_graphviz(n.canalizing_map())
Out[6]:
In [7]:
n = AND()
print( n)
print( 'k_r: %.2f - %.2f' % (n.input_redundancy(mode='node',bound='upper',norm=False), n.input_redundancy(mode='node',bound='lower',norm=False)))
print( 'k_e: %.2f - %.2f' % (n.effective_connectivity(mode='node',bound='upper',norm=False), n.effective_connectivity(mode='node',bound='lower',norm=False)))
print( 'k_s: %.2f - %.2f' % (n.input_symmetry(mode='node',bound='upper',norm=False), n.input_symmetry(mode='node',bound='lower',norm=False)))
print()
print( 'k_r: %s (upper)' % n.input_redundancy(mode='input',bound='upper'))
print( 'k_e: %s (upper)' % n.input_redundancy(mode='input',bound='upper'))
print
dfLUT, dfPI, dfTS = n.look_up_table(), n.schemata_look_up_table(type='pi'), n.schemata_look_up_table(type='ts')
display(pd.concat({'Original LUT':dfLUT,'PI Schema':dfPI,'TS Schema':dfTS}, axis=1).fillna('-'))
draw_canalizing_map_graphviz(n.canalizing_map())
Out[7]:
In [7]:
n = COPYx1()
n.name = 'CPx1'
print( n)
print( 'k_r: %.2f - %.2f' % (n.input_redundancy(mode='node',bound='upper',norm=False), n.input_redundancy(mode='node',bound='lower',norm=False)))
print( 'k_e: %.2f - %.2f' % (n.effective_connectivity(mode='node',bound='upper',norm=False), n.effective_connectivity(mode='node',bound='lower',norm=False)))
print('k_s: %.2f - %.2f' % (n.input_symmetry(mode='node',bound='upper',norm=False), n.input_symmetry(mode='node',bound='lower',norm=False)))
print
print( 'k_r: %s (upper)' % n.input_redundancy(mode='input',bound='upper'))
print( 'k_e: %s (upper)' % n.input_redundancy(mode='input',bound='upper'))
print()
dfLUT, dfPI, dfTS = n.look_up_table(), n.schemata_look_up_table(type='pi'), n.schemata_look_up_table(type='ts')
display(pd.concat({'Original LUT':dfLUT,'PI Schema':dfPI,'TS Schema':dfTS}, axis=1).fillna('-'))
draw_canalizing_map_graphviz(n.canalizing_map())
Out[7]:
In [8]:
n = RULE90()
n.name = 'R90'
print( n)
print( 'k_r: %.2f - %.2f' % (n.input_redundancy(mode='node',bound='upper',norm=False), n.input_redundancy(mode='node',bound='lower',norm=False)))
print( 'k_e: %.2f - %.2f' % (n.effective_connectivity(mode='node',bound='upper',norm=False), n.effective_connectivity(mode='node',bound='lower',norm=False)))
print( 'k_s: %.2f - %.2f' % (n.input_symmetry(mode='node',bound='upper',norm=False), n.input_symmetry(mode='node',bound='lower',norm=False)))
print()
print( 'k_r: %s (upper)' % n.input_redundancy(mode='input',bound='upper'))
print( 'k_e: %s (upper)' % n.input_redundancy(mode='input',bound='upper'))
print()
dfLUT, dfPI, dfTS = n.look_up_table(), n.schemata_look_up_table(type='pi'), n.schemata_look_up_table(type='ts')
display(pd.concat({'Original LUT':dfLUT,'PI Schema':dfPI,'TS Schema':dfTS}, axis=1).fillna('-'))
draw_canalizing_map_graphviz(n.canalizing_map())
Out[8]:
In [9]:
n = RULE110()
n.name = 'R110'
print( n)
print( 'k_r: %.2f - %.2f' % (n.input_redundancy(mode='node',bound='upper',norm=False), n.input_redundancy(mode='node',bound='lower',norm=False)))
print( 'k_e: %.2f - %.2f' % (n.effective_connectivity(mode='node',bound='upper',norm=False), n.effective_connectivity(mode='node',bound='lower',norm=False)))
print( 'k_s: %.2f - %.2f' % (n.input_symmetry(mode='node',bound='upper',norm=False), n.input_symmetry(mode='node',bound='lower',norm=False)))
print()
print( 'k_r: %s (upper)' % n.input_redundancy(mode='input',bound='upper'))
print( 'k_e: %s (upper)' % n.input_redundancy(mode='input',bound='upper'))
print()
dfLUT, dfPI, dfTS = n.look_up_table(), n.schemata_look_up_table(type='pi'), n.schemata_look_up_table(type='ts')
display(pd.concat({'Original LUT':dfLUT,'PI Schema':dfPI,'TS Schema':dfTS}, axis=1).fillna('-'))
draw_canalizing_map_graphviz(n.canalizing_map())
Out[9]:
In [ ]: