partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
map_vals
applies a function to each of the keys in a dictionary Args: func (callable): a function or indexable object dict_ (dict): a dictionary Returns: newdict: transformed dictionary CommandLine: python -m ubelt.util_dict map_vals Example: >>> import ubelt as ub ...
ubelt/util_dict.py
def map_vals(func, dict_): """ applies a function to each of the keys in a dictionary Args: func (callable): a function or indexable object dict_ (dict): a dictionary Returns: newdict: transformed dictionary CommandLine: python -m ubelt.util_dict map_vals Exam...
def map_vals(func, dict_): """ applies a function to each of the keys in a dictionary Args: func (callable): a function or indexable object dict_ (dict): a dictionary Returns: newdict: transformed dictionary CommandLine: python -m ubelt.util_dict map_vals Exam...
[ "applies", "a", "function", "to", "each", "of", "the", "keys", "in", "a", "dictionary" ]
Erotemic/ubelt
python
https://github.com/Erotemic/ubelt/blob/db802f3ad8abba025db74b54f86e6892b8927325/ubelt/util_dict.py#L451-L485
[ "def", "map_vals", "(", "func", ",", "dict_", ")", ":", "if", "not", "hasattr", "(", "func", ",", "'__call__'", ")", ":", "func", "=", "func", ".", "__getitem__", "keyval_list", "=", "[", "(", "key", ",", "func", "(", "val", ")", ")", "for", "key",...
db802f3ad8abba025db74b54f86e6892b8927325
valid
invert_dict
r""" Swaps the keys and values in a dictionary. Args: dict_ (dict): dictionary to invert unique_vals (bool): if False, inverted keys are returned in a set. The default is True. Returns: dict: inverted Notes: The must values be hashable. If the orig...
ubelt/util_dict.py
def invert_dict(dict_, unique_vals=True): r""" Swaps the keys and values in a dictionary. Args: dict_ (dict): dictionary to invert unique_vals (bool): if False, inverted keys are returned in a set. The default is True. Returns: dict: inverted Notes: The...
def invert_dict(dict_, unique_vals=True): r""" Swaps the keys and values in a dictionary. Args: dict_ (dict): dictionary to invert unique_vals (bool): if False, inverted keys are returned in a set. The default is True. Returns: dict: inverted Notes: The...
[ "r", "Swaps", "the", "keys", "and", "values", "in", "a", "dictionary", "." ]
Erotemic/ubelt
python
https://github.com/Erotemic/ubelt/blob/db802f3ad8abba025db74b54f86e6892b8927325/ubelt/util_dict.py#L529-L581
[ "def", "invert_dict", "(", "dict_", ",", "unique_vals", "=", "True", ")", ":", "if", "unique_vals", ":", "if", "isinstance", "(", "dict_", ",", "OrderedDict", ")", ":", "inverted", "=", "OrderedDict", "(", "(", "val", ",", "key", ")", "for", "key", ","...
db802f3ad8abba025db74b54f86e6892b8927325
valid
AutoDict.to_dict
Recursively casts a AutoDict into a regular dictionary. All nested AutoDict values are also converted. Returns: dict: a copy of this dict without autovivification Example: >>> from ubelt.util_dict import AutoDict >>> auto = AutoDict() >>> auto[1]...
ubelt/util_dict.py
def to_dict(self): """ Recursively casts a AutoDict into a regular dictionary. All nested AutoDict values are also converted. Returns: dict: a copy of this dict without autovivification Example: >>> from ubelt.util_dict import AutoDict >>> au...
def to_dict(self): """ Recursively casts a AutoDict into a regular dictionary. All nested AutoDict values are also converted. Returns: dict: a copy of this dict without autovivification Example: >>> from ubelt.util_dict import AutoDict >>> au...
[ "Recursively", "casts", "a", "AutoDict", "into", "a", "regular", "dictionary", ".", "All", "nested", "AutoDict", "values", "are", "also", "converted", "." ]
Erotemic/ubelt
python
https://github.com/Erotemic/ubelt/blob/db802f3ad8abba025db74b54f86e6892b8927325/ubelt/util_dict.py#L66-L85
[ "def", "to_dict", "(", "self", ")", ":", "return", "self", ".", "_base", "(", "(", "key", ",", "(", "value", ".", "to_dict", "(", ")", "if", "isinstance", "(", "value", ",", "AutoDict", ")", "else", "value", ")", ")", "for", "key", ",", "value", ...
db802f3ad8abba025db74b54f86e6892b8927325
valid
_win32_can_symlink
CommandLine: python -m ubelt._win32_links _win32_can_symlink Example: >>> # xdoc: +REQUIRES(WIN32) >>> import ubelt as ub >>> _win32_can_symlink(verbose=1, force=1, testing=1)
ubelt/_win32_links.py
def _win32_can_symlink(verbose=0, force=0, testing=0): """ CommandLine: python -m ubelt._win32_links _win32_can_symlink Example: >>> # xdoc: +REQUIRES(WIN32) >>> import ubelt as ub >>> _win32_can_symlink(verbose=1, force=1, testing=1) """ global __win32_can_symlink__...
def _win32_can_symlink(verbose=0, force=0, testing=0): """ CommandLine: python -m ubelt._win32_links _win32_can_symlink Example: >>> # xdoc: +REQUIRES(WIN32) >>> import ubelt as ub >>> _win32_can_symlink(verbose=1, force=1, testing=1) """ global __win32_can_symlink__...
[ "CommandLine", ":", "python", "-", "m", "ubelt", ".", "_win32_links", "_win32_can_symlink" ]
Erotemic/ubelt
python
https://github.com/Erotemic/ubelt/blob/db802f3ad8abba025db74b54f86e6892b8927325/ubelt/_win32_links.py#L34-L138
[ "def", "_win32_can_symlink", "(", "verbose", "=", "0", ",", "force", "=", "0", ",", "testing", "=", "0", ")", ":", "global", "__win32_can_symlink__", "if", "verbose", ":", "print", "(", "'__win32_can_symlink__ = {!r}'", ".", "format", "(", "__win32_can_symlink__...
db802f3ad8abba025db74b54f86e6892b8927325
valid
_symlink
Windows helper for ub.symlink
ubelt/_win32_links.py
def _symlink(path, link, overwrite=0, verbose=0): """ Windows helper for ub.symlink """ if exists(link) and not os.path.islink(link): # On windows a broken link might still exist as a hard link or a # junction. Overwrite it if it is a file and we cannot symlink. # However, if it ...
def _symlink(path, link, overwrite=0, verbose=0): """ Windows helper for ub.symlink """ if exists(link) and not os.path.islink(link): # On windows a broken link might still exist as a hard link or a # junction. Overwrite it if it is a file and we cannot symlink. # However, if it ...
[ "Windows", "helper", "for", "ub", ".", "symlink" ]
Erotemic/ubelt
python
https://github.com/Erotemic/ubelt/blob/db802f3ad8abba025db74b54f86e6892b8927325/ubelt/_win32_links.py#L141-L191
[ "def", "_symlink", "(", "path", ",", "link", ",", "overwrite", "=", "0", ",", "verbose", "=", "0", ")", ":", "if", "exists", "(", "link", ")", "and", "not", "os", ".", "path", ".", "islink", "(", "link", ")", ":", "# On windows a broken link might stil...
db802f3ad8abba025db74b54f86e6892b8927325
valid
_win32_symlink2
Perform a real symbolic link if possible. However, on most versions of windows you need special privledges to create a real symlink. Therefore, we try to create a symlink, but if that fails we fallback to using a junction. AFAIK, the main difference between symlinks and junctions are that symlinks can ...
ubelt/_win32_links.py
def _win32_symlink2(path, link, allow_fallback=True, verbose=0): """ Perform a real symbolic link if possible. However, on most versions of windows you need special privledges to create a real symlink. Therefore, we try to create a symlink, but if that fails we fallback to using a junction. AFAIK, ...
def _win32_symlink2(path, link, allow_fallback=True, verbose=0): """ Perform a real symbolic link if possible. However, on most versions of windows you need special privledges to create a real symlink. Therefore, we try to create a symlink, but if that fails we fallback to using a junction. AFAIK, ...
[ "Perform", "a", "real", "symbolic", "link", "if", "possible", ".", "However", "on", "most", "versions", "of", "windows", "you", "need", "special", "privledges", "to", "create", "a", "real", "symlink", ".", "Therefore", "we", "try", "to", "create", "a", "sy...
Erotemic/ubelt
python
https://github.com/Erotemic/ubelt/blob/db802f3ad8abba025db74b54f86e6892b8927325/ubelt/_win32_links.py#L194-L210
[ "def", "_win32_symlink2", "(", "path", ",", "link", ",", "allow_fallback", "=", "True", ",", "verbose", "=", "0", ")", ":", "if", "_win32_can_symlink", "(", ")", ":", "return", "_win32_symlink", "(", "path", ",", "link", ",", "verbose", ")", "else", ":",...
db802f3ad8abba025db74b54f86e6892b8927325
valid
_win32_symlink
Creates real symlink. This will only work in versions greater than Windows Vista. Creating real symlinks requires admin permissions or at least specially enabled symlink permissions. On Windows 10 enabling developer mode should give you these permissions.
ubelt/_win32_links.py
def _win32_symlink(path, link, verbose=0): """ Creates real symlink. This will only work in versions greater than Windows Vista. Creating real symlinks requires admin permissions or at least specially enabled symlink permissions. On Windows 10 enabling developer mode should give you these permission...
def _win32_symlink(path, link, verbose=0): """ Creates real symlink. This will only work in versions greater than Windows Vista. Creating real symlinks requires admin permissions or at least specially enabled symlink permissions. On Windows 10 enabling developer mode should give you these permission...
[ "Creates", "real", "symlink", ".", "This", "will", "only", "work", "in", "versions", "greater", "than", "Windows", "Vista", ".", "Creating", "real", "symlinks", "requires", "admin", "permissions", "or", "at", "least", "specially", "enabled", "symlink", "permissi...
Erotemic/ubelt
python
https://github.com/Erotemic/ubelt/blob/db802f3ad8abba025db74b54f86e6892b8927325/ubelt/_win32_links.py#L213-L246
[ "def", "_win32_symlink", "(", "path", ",", "link", ",", "verbose", "=", "0", ")", ":", "from", "ubelt", "import", "util_cmd", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "# directory symbolic link", "if", "verbose", ":", "print", "(", ...
db802f3ad8abba025db74b54f86e6892b8927325
valid
_win32_junction
On older (pre 10) versions of windows we need admin privledges to make symlinks, however junctions seem to work. For paths we do a junction (softlink) and for files we use a hard link CommandLine: python -m ubelt._win32_links _win32_junction Example: >>> # xdoc: +REQUIRES(WIN32) ...
ubelt/_win32_links.py
def _win32_junction(path, link, verbose=0): """ On older (pre 10) versions of windows we need admin privledges to make symlinks, however junctions seem to work. For paths we do a junction (softlink) and for files we use a hard link CommandLine: python -m ubelt._win32_links _win32_junction ...
def _win32_junction(path, link, verbose=0): """ On older (pre 10) versions of windows we need admin privledges to make symlinks, however junctions seem to work. For paths we do a junction (softlink) and for files we use a hard link CommandLine: python -m ubelt._win32_links _win32_junction ...
[ "On", "older", "(", "pre", "10", ")", "versions", "of", "windows", "we", "need", "admin", "privledges", "to", "make", "symlinks", "however", "junctions", "seem", "to", "work", "." ]
Erotemic/ubelt
python
https://github.com/Erotemic/ubelt/blob/db802f3ad8abba025db74b54f86e6892b8927325/ubelt/_win32_links.py#L249-L316
[ "def", "_win32_junction", "(", "path", ",", "link", ",", "verbose", "=", "0", ")", ":", "# junctions store absolute paths", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "link", "=", "os", ".", "path", ".", "abspath", "(", "link", "...
db802f3ad8abba025db74b54f86e6892b8927325
valid
_win32_is_junction
Determines if a path is a win32 junction CommandLine: python -m ubelt._win32_links _win32_is_junction Example: >>> # xdoc: +REQUIRES(WIN32) >>> import ubelt as ub >>> root = ub.ensure_app_cache_dir('ubelt', 'win32_junction') >>> ub.delete(root) >>> ub.ensuredir(...
ubelt/_win32_links.py
def _win32_is_junction(path): """ Determines if a path is a win32 junction CommandLine: python -m ubelt._win32_links _win32_is_junction Example: >>> # xdoc: +REQUIRES(WIN32) >>> import ubelt as ub >>> root = ub.ensure_app_cache_dir('ubelt', 'win32_junction') >>>...
def _win32_is_junction(path): """ Determines if a path is a win32 junction CommandLine: python -m ubelt._win32_links _win32_is_junction Example: >>> # xdoc: +REQUIRES(WIN32) >>> import ubelt as ub >>> root = ub.ensure_app_cache_dir('ubelt', 'win32_junction') >>>...
[ "Determines", "if", "a", "path", "is", "a", "win32", "junction" ]
Erotemic/ubelt
python
https://github.com/Erotemic/ubelt/blob/db802f3ad8abba025db74b54f86e6892b8927325/ubelt/_win32_links.py#L319-L345
[ "def", "_win32_is_junction", "(", "path", ")", ":", "if", "not", "exists", "(", "path", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "if", "not", "os", ".", "path", ".", "islink", "(", "path", ")", ":", "return", "True"...
db802f3ad8abba025db74b54f86e6892b8927325
valid
_win32_read_junction
Returns the location that the junction points, raises ValueError if path is not a junction. CommandLine: python -m ubelt._win32_links _win32_read_junction Example: >>> # xdoc: +REQUIRES(WIN32) >>> import ubelt as ub >>> root = ub.ensure_app_cache_dir('ubelt', 'win32_junctio...
ubelt/_win32_links.py
def _win32_read_junction(path): """ Returns the location that the junction points, raises ValueError if path is not a junction. CommandLine: python -m ubelt._win32_links _win32_read_junction Example: >>> # xdoc: +REQUIRES(WIN32) >>> import ubelt as ub >>> root = ub....
def _win32_read_junction(path): """ Returns the location that the junction points, raises ValueError if path is not a junction. CommandLine: python -m ubelt._win32_links _win32_read_junction Example: >>> # xdoc: +REQUIRES(WIN32) >>> import ubelt as ub >>> root = ub....
[ "Returns", "the", "location", "that", "the", "junction", "points", "raises", "ValueError", "if", "path", "is", "not", "a", "junction", "." ]
Erotemic/ubelt
python
https://github.com/Erotemic/ubelt/blob/db802f3ad8abba025db74b54f86e6892b8927325/ubelt/_win32_links.py#L348-L411
[ "def", "_win32_read_junction", "(", "path", ")", ":", "if", "not", "jwfs", ".", "is_reparse_point", "(", "path", ")", ":", "raise", "ValueError", "(", "'not a junction'", ")", "# --- Older version based on using shell commands ---", "# if not exists(path):", "# if six...
db802f3ad8abba025db74b54f86e6892b8927325
valid
_win32_rmtree
rmtree for win32 that treats junctions like directory symlinks. The junction removal portion may not be safe on race conditions. There is a known issue that prevents shutil.rmtree from deleting directories with junctions. https://bugs.python.org/issue31226
ubelt/_win32_links.py
def _win32_rmtree(path, verbose=0): """ rmtree for win32 that treats junctions like directory symlinks. The junction removal portion may not be safe on race conditions. There is a known issue that prevents shutil.rmtree from deleting directories with junctions. https://bugs.python.org/issue3122...
def _win32_rmtree(path, verbose=0): """ rmtree for win32 that treats junctions like directory symlinks. The junction removal portion may not be safe on race conditions. There is a known issue that prevents shutil.rmtree from deleting directories with junctions. https://bugs.python.org/issue3122...
[ "rmtree", "for", "win32", "that", "treats", "junctions", "like", "directory", "symlinks", ".", "The", "junction", "removal", "portion", "may", "not", "be", "safe", "on", "race", "conditions", "." ]
Erotemic/ubelt
python
https://github.com/Erotemic/ubelt/blob/db802f3ad8abba025db74b54f86e6892b8927325/ubelt/_win32_links.py#L414-L463
[ "def", "_win32_rmtree", "(", "path", ",", "verbose", "=", "0", ")", ":", "# --- old version using the shell ---", "# def _rmjunctions(root):", "# subdirs = []", "# for type_or_size, name, pointed in _win32_dir(root):", "# if type_or_size == '<DIR>':", "# sub...
db802f3ad8abba025db74b54f86e6892b8927325
valid
_win32_is_hardlinked
Test if two hard links point to the same location CommandLine: python -m ubelt._win32_links _win32_is_hardlinked Example: >>> # xdoc: +REQUIRES(WIN32) >>> import ubelt as ub >>> root = ub.ensure_app_cache_dir('ubelt', 'win32_hardlink') >>> ub.delete(root) >>> ub...
ubelt/_win32_links.py
def _win32_is_hardlinked(fpath1, fpath2): """ Test if two hard links point to the same location CommandLine: python -m ubelt._win32_links _win32_is_hardlinked Example: >>> # xdoc: +REQUIRES(WIN32) >>> import ubelt as ub >>> root = ub.ensure_app_cache_dir('ubelt', 'win32...
def _win32_is_hardlinked(fpath1, fpath2): """ Test if two hard links point to the same location CommandLine: python -m ubelt._win32_links _win32_is_hardlinked Example: >>> # xdoc: +REQUIRES(WIN32) >>> import ubelt as ub >>> root = ub.ensure_app_cache_dir('ubelt', 'win32...
[ "Test", "if", "two", "hard", "links", "point", "to", "the", "same", "location" ]
Erotemic/ubelt
python
https://github.com/Erotemic/ubelt/blob/db802f3ad8abba025db74b54f86e6892b8927325/ubelt/_win32_links.py#L466-L519
[ "def", "_win32_is_hardlinked", "(", "fpath1", ",", "fpath2", ")", ":", "# NOTE: jwf.samefile(fpath1, fpath2) seems to behave differently", "def", "get_read_handle", "(", "fpath", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "fpath", ")", ":", "dwFlagsAndAtt...
db802f3ad8abba025db74b54f86e6892b8927325
valid
_win32_dir
Using the windows cmd shell to get information about a directory
ubelt/_win32_links.py
def _win32_dir(path, star=''): """ Using the windows cmd shell to get information about a directory """ from ubelt import util_cmd import re wrapper = 'cmd /S /C "{}"' # the /S will preserve all inner quotes command = 'dir /-C "{}"{}'.format(path, star) wrapped = wrapper.format(command)...
def _win32_dir(path, star=''): """ Using the windows cmd shell to get information about a directory """ from ubelt import util_cmd import re wrapper = 'cmd /S /C "{}"' # the /S will preserve all inner quotes command = 'dir /-C "{}"{}'.format(path, star) wrapped = wrapper.format(command)...
[ "Using", "the", "windows", "cmd", "shell", "to", "get", "information", "about", "a", "directory" ]
Erotemic/ubelt
python
https://github.com/Erotemic/ubelt/blob/db802f3ad8abba025db74b54f86e6892b8927325/ubelt/_win32_links.py#L522-L558
[ "def", "_win32_dir", "(", "path", ",", "star", "=", "''", ")", ":", "from", "ubelt", "import", "util_cmd", "import", "re", "wrapper", "=", "'cmd /S /C \"{}\"'", "# the /S will preserve all inner quotes", "command", "=", "'dir /-C \"{}\"{}'", ".", "format", "(", "p...
db802f3ad8abba025db74b54f86e6892b8927325
valid
parse_generator_doubling
Returns generators that double with each value returned Config includes optional start value
sample_extension.py
def parse_generator_doubling(config): """ Returns generators that double with each value returned Config includes optional start value """ start = 1 if 'start' in config: start = int(config['start']) # We cannot simply use start as the variable, because of scoping # limitations ...
def parse_generator_doubling(config): """ Returns generators that double with each value returned Config includes optional start value """ start = 1 if 'start' in config: start = int(config['start']) # We cannot simply use start as the variable, because of scoping # limitations ...
[ "Returns", "generators", "that", "double", "with", "each", "value", "returned", "Config", "includes", "optional", "start", "value" ]
svanoort/pyresttest
python
https://github.com/svanoort/pyresttest/blob/f92acf8e838c4623ddd8e12e880f31046ff9317f/sample_extension.py#L53-L67
[ "def", "parse_generator_doubling", "(", "config", ")", ":", "start", "=", "1", "if", "'start'", "in", "config", ":", "start", "=", "int", "(", "config", "[", "'start'", "]", ")", "# We cannot simply use start as the variable, because of scoping", "# limitations", "d...
f92acf8e838c4623ddd8e12e880f31046ff9317f
valid
ContainsValidator.parse
Parse a contains validator, which takes as the config a simple string to find
sample_extension.py
def parse(config): """ Parse a contains validator, which takes as the config a simple string to find """ if not isinstance(config, basestring): raise TypeError("Contains input must be a simple string") validator = ContainsValidator() validator.contains_string = config ...
def parse(config): """ Parse a contains validator, which takes as the config a simple string to find """ if not isinstance(config, basestring): raise TypeError("Contains input must be a simple string") validator = ContainsValidator() validator.contains_string = config ...
[ "Parse", "a", "contains", "validator", "which", "takes", "as", "the", "config", "a", "simple", "string", "to", "find" ]
svanoort/pyresttest
python
https://github.com/svanoort/pyresttest/blob/f92acf8e838c4623ddd8e12e880f31046ff9317f/sample_extension.py#L29-L35
[ "def", "parse", "(", "config", ")", ":", "if", "not", "isinstance", "(", "config", ",", "basestring", ")", ":", "raise", "TypeError", "(", "\"Contains input must be a simple string\"", ")", "validator", "=", "ContainsValidator", "(", ")", "validator", ".", "cont...
f92acf8e838c4623ddd8e12e880f31046ff9317f
valid
retrieve_adjacency_matrix
Retrieve the adjacency matrix from the nx.DiGraph or numpy array.
cdt/utils/metrics.py
def retrieve_adjacency_matrix(graph, order_nodes=None, weight=False): """Retrieve the adjacency matrix from the nx.DiGraph or numpy array.""" if isinstance(graph, np.ndarray): return graph elif isinstance(graph, nx.DiGraph): if order_nodes is None: order_nodes = graph.nodes() ...
def retrieve_adjacency_matrix(graph, order_nodes=None, weight=False): """Retrieve the adjacency matrix from the nx.DiGraph or numpy array.""" if isinstance(graph, np.ndarray): return graph elif isinstance(graph, nx.DiGraph): if order_nodes is None: order_nodes = graph.nodes() ...
[ "Retrieve", "the", "adjacency", "matrix", "from", "the", "nx", ".", "DiGraph", "or", "numpy", "array", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/utils/metrics.py#L40-L52
[ "def", "retrieve_adjacency_matrix", "(", "graph", ",", "order_nodes", "=", "None", ",", "weight", "=", "False", ")", ":", "if", "isinstance", "(", "graph", ",", "np", ".", "ndarray", ")", ":", "return", "graph", "elif", "isinstance", "(", "graph", ",", "...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
precision_recall
r"""Compute precision-recall statistics for directed graphs. Precision recall statistics are useful to compare algorithms that make predictions with a confidence score. Using these statistics, performance of an algorithms given a set threshold (confidence score) can be approximated. Area unde...
cdt/utils/metrics.py
def precision_recall(target, prediction, low_confidence_undirected=False): r"""Compute precision-recall statistics for directed graphs. Precision recall statistics are useful to compare algorithms that make predictions with a confidence score. Using these statistics, performance of an algorithms ...
def precision_recall(target, prediction, low_confidence_undirected=False): r"""Compute precision-recall statistics for directed graphs. Precision recall statistics are useful to compare algorithms that make predictions with a confidence score. Using these statistics, performance of an algorithms ...
[ "r", "Compute", "precision", "-", "recall", "statistics", "for", "directed", "graphs", ".", "Precision", "recall", "statistics", "are", "useful", "to", "compare", "algorithms", "that", "make", "predictions", "with", "a", "confidence", "score", ".", "Using", "the...
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/utils/metrics.py#L55-L107
[ "def", "precision_recall", "(", "target", ",", "prediction", ",", "low_confidence_undirected", "=", "False", ")", ":", "true_labels", "=", "retrieve_adjacency_matrix", "(", "target", ")", "pred", "=", "retrieve_adjacency_matrix", "(", "prediction", ",", "target", "....
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
SHD
r"""Compute the Structural Hamming Distance. The Structural Hamming Distance (SHD) is a standard distance to compare graphs by their adjacency matrix. It consists in computing the difference between the two (binary) adjacency matrixes: every edge that is either missing or not in the target graph i...
cdt/utils/metrics.py
def SHD(target, pred, double_for_anticausal=True): r"""Compute the Structural Hamming Distance. The Structural Hamming Distance (SHD) is a standard distance to compare graphs by their adjacency matrix. It consists in computing the difference between the two (binary) adjacency matrixes: every edge t...
def SHD(target, pred, double_for_anticausal=True): r"""Compute the Structural Hamming Distance. The Structural Hamming Distance (SHD) is a standard distance to compare graphs by their adjacency matrix. It consists in computing the difference between the two (binary) adjacency matrixes: every edge t...
[ "r", "Compute", "the", "Structural", "Hamming", "Distance", ".", "The", "Structural", "Hamming", "Distance", "(", "SHD", ")", "is", "a", "standard", "distance", "to", "compare", "graphs", "by", "their", "adjacency", "matrix", ".", "It", "consists", "in", "co...
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/utils/metrics.py#L110-L150
[ "def", "SHD", "(", "target", ",", "pred", ",", "double_for_anticausal", "=", "True", ")", ":", "true_labels", "=", "retrieve_adjacency_matrix", "(", "target", ")", "predictions", "=", "retrieve_adjacency_matrix", "(", "pred", ",", "target", ".", "nodes", "(", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
SID
Compute the Strutural Intervention Distance. [R wrapper] The Structural Intervention Distance (SID) is a new distance for graphs introduced by Peters and Bühlmann (2013). This distance was created to account for the shortcomings of the SHD metric for a causal sense. It consists in computing th...
cdt/utils/metrics.py
def SID(target, pred): """Compute the Strutural Intervention Distance. [R wrapper] The Structural Intervention Distance (SID) is a new distance for graphs introduced by Peters and Bühlmann (2013). This distance was created to account for the shortcomings of the SHD metric for a causal sense. ...
def SID(target, pred): """Compute the Strutural Intervention Distance. [R wrapper] The Structural Intervention Distance (SID) is a new distance for graphs introduced by Peters and Bühlmann (2013). This distance was created to account for the shortcomings of the SHD metric for a causal sense. ...
[ "Compute", "the", "Strutural", "Intervention", "Distance", ".", "[", "R", "wrapper", "]", "The", "Structural", "Intervention", "Distance", "(", "SID", ")", "is", "a", "new", "distance", "for", "graphs", "introduced", "by", "Peters", "and", "Bühlmann", "(", "...
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/utils/metrics.py#L153-L216
[ "def", "SID", "(", "target", ",", "pred", ")", ":", "if", "not", "RPackages", ".", "SID", ":", "raise", "ImportError", "(", "\"SID R package is not available. Please check your installation.\"", ")", "true_labels", "=", "retrieve_adjacency_matrix", "(", "target", ")",...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
CCDr.create_graph_from_data
Apply causal discovery on observational data using CCDr. Args: data (pandas.DataFrame): DataFrame containing the data Returns: networkx.DiGraph: Solution given by the CCDR algorithm.
cdt/causality/graph/CCDr.py
def create_graph_from_data(self, data, **kwargs): """Apply causal discovery on observational data using CCDr. Args: data (pandas.DataFrame): DataFrame containing the data Returns: networkx.DiGraph: Solution given by the CCDR algorithm. """ # Building set...
def create_graph_from_data(self, data, **kwargs): """Apply causal discovery on observational data using CCDr. Args: data (pandas.DataFrame): DataFrame containing the data Returns: networkx.DiGraph: Solution given by the CCDR algorithm. """ # Building set...
[ "Apply", "causal", "discovery", "on", "observational", "data", "using", "CCDr", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/CCDr.py#L83-L96
[ "def", "create_graph_from_data", "(", "self", ",", "data", ",", "*", "*", "kwargs", ")", ":", "# Building setup w/ arguments.", "self", ".", "arguments", "[", "'{VERBOSE}'", "]", "=", "str", "(", "self", ".", "verbose", ")", ".", "upper", "(", ")", "result...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
AcyclicGraphGenerator.init_variables
Redefine the causes of the graph.
cdt/generators/acyclic_graph_generator.py
def init_variables(self, verbose=False): """Redefine the causes of the graph.""" for j in range(1, self.nodes): nb_parents = np.random.randint(0, min([self.parents_max, j])+1) for i in np.random.choice(range(0, j), nb_parents, replace=False): self.adjacency_matrix...
def init_variables(self, verbose=False): """Redefine the causes of the graph.""" for j in range(1, self.nodes): nb_parents = np.random.randint(0, min([self.parents_max, j])+1) for i in np.random.choice(range(0, j), nb_parents, replace=False): self.adjacency_matrix...
[ "Redefine", "the", "causes", "of", "the", "graph", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/generators/acyclic_graph_generator.py#L77-L97
[ "def", "init_variables", "(", "self", ",", "verbose", "=", "False", ")", ":", "for", "j", "in", "range", "(", "1", ",", "self", ".", "nodes", ")", ":", "nb_parents", "=", "np", ".", "random", ".", "randint", "(", "0", ",", "min", "(", "[", "self"...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
AcyclicGraphGenerator.generate
Generate data from an FCM containing cycles.
cdt/generators/acyclic_graph_generator.py
def generate(self, rescale=True): """Generate data from an FCM containing cycles.""" if self.cfunctions is None: self.init_variables() for i in nx.topological_sort(self.g): # Root cause if not sum(self.adjacency_matrix[:, i]): self.data['V{}'...
def generate(self, rescale=True): """Generate data from an FCM containing cycles.""" if self.cfunctions is None: self.init_variables() for i in nx.topological_sort(self.g): # Root cause if not sum(self.adjacency_matrix[:, i]): self.data['V{}'...
[ "Generate", "data", "from", "an", "FCM", "containing", "cycles", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/generators/acyclic_graph_generator.py#L99-L115
[ "def", "generate", "(", "self", ",", "rescale", "=", "True", ")", ":", "if", "self", ".", "cfunctions", "is", "None", ":", "self", ".", "init_variables", "(", ")", "for", "i", "in", "nx", ".", "topological_sort", "(", "self", ".", "g", ")", ":", "#...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
AcyclicGraphGenerator.to_csv
Save data to the csv format by default, in two separate files. Optional keyword arguments can be passed to pandas.
cdt/generators/acyclic_graph_generator.py
def to_csv(self, fname_radical, **kwargs): """ Save data to the csv format by default, in two separate files. Optional keyword arguments can be passed to pandas. """ if self.data is not None: self.data.to_csv(fname_radical+'_data.csv', index=False, **kwargs) ...
def to_csv(self, fname_radical, **kwargs): """ Save data to the csv format by default, in two separate files. Optional keyword arguments can be passed to pandas. """ if self.data is not None: self.data.to_csv(fname_radical+'_data.csv', index=False, **kwargs) ...
[ "Save", "data", "to", "the", "csv", "format", "by", "default", "in", "two", "separate", "files", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/generators/acyclic_graph_generator.py#L117-L131
[ "def", "to_csv", "(", "self", ",", "fname_radical", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "data", "is", "not", "None", ":", "self", ".", "data", ".", "to_csv", "(", "fname_radical", "+", "'_data.csv'", ",", "index", "=", "False", ",",...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
launch_R_script
Launch an R script, starting from a template and replacing text in file before execution. Args: template (str): path to the template of the R script arguments (dict): Arguments that modify the template's placeholders with arguments output_function (function): Function to exe...
cdt/utils/R.py
def launch_R_script(template, arguments, output_function=None, verbose=True, debug=False): """Launch an R script, starting from a template and replacing text in file before execution. Args: template (str): path to the template of the R script arguments (dict): Arguments ...
def launch_R_script(template, arguments, output_function=None, verbose=True, debug=False): """Launch an R script, starting from a template and replacing text in file before execution. Args: template (str): path to the template of the R script arguments (dict): Arguments ...
[ "Launch", "an", "R", "script", "starting", "from", "a", "template", "and", "replacing", "text", "in", "file", "before", "execution", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/utils/R.py#L139-L196
[ "def", "launch_R_script", "(", "template", ",", "arguments", ",", "output_function", "=", "None", ",", "verbose", "=", "True", ",", "debug", "=", "False", ")", ":", "id", "=", "str", "(", "uuid", ".", "uuid4", "(", ")", ")", "os", ".", "makedirs", "(...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
DefaultRPackages.check_R_package
Execute a subprocess to check the package's availability. Args: package (str): Name of the package to be tested. Returns: bool: `True` if the package is available, `False` otherwise
cdt/utils/R.py
def check_R_package(self, package): """Execute a subprocess to check the package's availability. Args: package (str): Name of the package to be tested. Returns: bool: `True` if the package is available, `False` otherwise """ test_package = not bool(launc...
def check_R_package(self, package): """Execute a subprocess to check the package's availability. Args: package (str): Name of the package to be tested. Returns: bool: `True` if the package is available, `False` otherwise """ test_package = not bool(launc...
[ "Execute", "a", "subprocess", "to", "check", "the", "package", "s", "availability", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/utils/R.py#L126-L136
[ "def", "check_R_package", "(", "self", ",", "package", ")", ":", "test_package", "=", "not", "bool", "(", "launch_R_script", "(", "\"{}/R_templates/test_import.R\"", ".", "format", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "realpat...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
bin_variable
Bin variables w/ normalization.
cdt/independence/stats/all_types.py
def bin_variable(var, bins='fd'): # bin with normalization """Bin variables w/ normalization.""" var = np.array(var).astype(np.float) var = (var - np.mean(var)) / np.std(var) var = np.digitize(var, np.histogram(var, bins=bins)[1]) return var
def bin_variable(var, bins='fd'): # bin with normalization """Bin variables w/ normalization.""" var = np.array(var).astype(np.float) var = (var - np.mean(var)) / np.std(var) var = np.digitize(var, np.histogram(var, bins=bins)[1]) return var
[ "Bin", "variables", "w", "/", "normalization", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/independence/stats/all_types.py#L34-L40
[ "def", "bin_variable", "(", "var", ",", "bins", "=", "'fd'", ")", ":", "# bin with normalization", "var", "=", "np", ".", "array", "(", "var", ")", ".", "astype", "(", "np", ".", "float", ")", "var", "=", "(", "var", "-", "np", ".", "mean", "(", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
AdjMI.predict
Perform the independence test. :param a: input data :param b: input data :type a: array-like, numerical data :type b: array-like, numerical data :return: dependency statistic (1=Highly dependent, 0=Not dependent) :rtype: float
cdt/independence/stats/all_types.py
def predict(self, a, b, **kwargs): """Perform the independence test. :param a: input data :param b: input data :type a: array-like, numerical data :type b: array-like, numerical data :return: dependency statistic (1=Highly dependent, 0=Not dependent) :rtype: floa...
def predict(self, a, b, **kwargs): """Perform the independence test. :param a: input data :param b: input data :type a: array-like, numerical data :type b: array-like, numerical data :return: dependency statistic (1=Highly dependent, 0=Not dependent) :rtype: floa...
[ "Perform", "the", "independence", "test", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/independence/stats/all_types.py#L62-L74
[ "def", "predict", "(", "self", ",", "a", ",", "b", ",", "*", "*", "kwargs", ")", ":", "binning_alg", "=", "kwargs", ".", "get", "(", "'bins'", ",", "'fd'", ")", "return", "metrics", ".", "adjusted_mutual_info_score", "(", "bin_variable", "(", "a", ",",...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
GraphModel.predict
Orient a graph using the method defined by the arguments. Depending on the type of `graph`, this function process to execute different functions: 1. If ``graph`` is a ``networkx.DiGraph``, then ``self.orient_directed_graph`` is executed. 2. If ``graph`` is a ``networkx.Graph``, then ``...
cdt/causality/graph/model.py
def predict(self, df_data, graph=None, **kwargs): """Orient a graph using the method defined by the arguments. Depending on the type of `graph`, this function process to execute different functions: 1. If ``graph`` is a ``networkx.DiGraph``, then ``self.orient_directed_graph`` is execu...
def predict(self, df_data, graph=None, **kwargs): """Orient a graph using the method defined by the arguments. Depending on the type of `graph`, this function process to execute different functions: 1. If ``graph`` is a ``networkx.DiGraph``, then ``self.orient_directed_graph`` is execu...
[ "Orient", "a", "graph", "using", "the", "method", "defined", "by", "the", "arguments", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/model.py#L44-L70
[ "def", "predict", "(", "self", ",", "df_data", ",", "graph", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "graph", "is", "None", ":", "return", "self", ".", "create_graph_from_data", "(", "df_data", ",", "*", "*", "kwargs", ")", "elif", "isi...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
graph_evaluation
Evaluate a graph taking account of the hardware.
cdt/causality/graph/CGNN.py
def graph_evaluation(data, adj_matrix, gpu=None, gpu_id=0, **kwargs): """Evaluate a graph taking account of the hardware.""" gpu = SETTINGS.get_default(gpu=gpu) device = 'cuda:{}'.format(gpu_id) if gpu else 'cpu' obs = th.FloatTensor(data).to(device) cgnn = CGNN_model(adj_matrix, data.shape[0], gpu_...
def graph_evaluation(data, adj_matrix, gpu=None, gpu_id=0, **kwargs): """Evaluate a graph taking account of the hardware.""" gpu = SETTINGS.get_default(gpu=gpu) device = 'cuda:{}'.format(gpu_id) if gpu else 'cpu' obs = th.FloatTensor(data).to(device) cgnn = CGNN_model(adj_matrix, data.shape[0], gpu_...
[ "Evaluate", "a", "graph", "taking", "account", "of", "the", "hardware", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/CGNN.py#L152-L159
[ "def", "graph_evaluation", "(", "data", ",", "adj_matrix", ",", "gpu", "=", "None", ",", "gpu_id", "=", "0", ",", "*", "*", "kwargs", ")", ":", "gpu", "=", "SETTINGS", ".", "get_default", "(", "gpu", "=", "gpu", ")", "device", "=", "'cuda:{}'", ".", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
parallel_graph_evaluation
Parallelize the various runs of CGNN to evaluate a graph.
cdt/causality/graph/CGNN.py
def parallel_graph_evaluation(data, adj_matrix, nb_runs=16, nb_jobs=None, **kwargs): """Parallelize the various runs of CGNN to evaluate a graph.""" nb_jobs = SETTINGS.get_default(nb_jobs=nb_jobs) if nb_runs == 1: return graph_evaluation(data, adj_matrix, **kwargs) ...
def parallel_graph_evaluation(data, adj_matrix, nb_runs=16, nb_jobs=None, **kwargs): """Parallelize the various runs of CGNN to evaluate a graph.""" nb_jobs = SETTINGS.get_default(nb_jobs=nb_jobs) if nb_runs == 1: return graph_evaluation(data, adj_matrix, **kwargs) ...
[ "Parallelize", "the", "various", "runs", "of", "CGNN", "to", "evaluate", "a", "graph", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/CGNN.py#L162-L172
[ "def", "parallel_graph_evaluation", "(", "data", ",", "adj_matrix", ",", "nb_runs", "=", "16", ",", "nb_jobs", "=", "None", ",", "*", "*", "kwargs", ")", ":", "nb_jobs", "=", "SETTINGS", ".", "get_default", "(", "nb_jobs", "=", "nb_jobs", ")", "if", "nb_...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
hill_climbing
Hill Climbing optimization: a greedy exploration algorithm.
cdt/causality/graph/CGNN.py
def hill_climbing(data, graph, **kwargs): """Hill Climbing optimization: a greedy exploration algorithm.""" nodelist = list(data.columns) data = scale(data.values).astype('float32') tested_candidates = [nx.adj_matrix(graph, nodelist=nodelist, weight=None)] best_score = parallel_graph_evaluation(data...
def hill_climbing(data, graph, **kwargs): """Hill Climbing optimization: a greedy exploration algorithm.""" nodelist = list(data.columns) data = scale(data.values).astype('float32') tested_candidates = [nx.adj_matrix(graph, nodelist=nodelist, weight=None)] best_score = parallel_graph_evaluation(data...
[ "Hill", "Climbing", "optimization", ":", "a", "greedy", "exploration", "algorithm", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/CGNN.py#L175-L199
[ "def", "hill_climbing", "(", "data", ",", "graph", ",", "*", "*", "kwargs", ")", ":", "nodelist", "=", "list", "(", "data", ".", "columns", ")", "data", "=", "scale", "(", "data", ".", "values", ")", ".", "astype", "(", "'float32'", ")", "tested_cand...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
CGNN_model.forward
Generate according to the topological order of the graph.
cdt/causality/graph/CGNN.py
def forward(self): """Generate according to the topological order of the graph.""" self.noise.data.normal_() if not self.confounding: for i in self.topological_order: self.generated[i] = self.blocks[i](th.cat([v for c in [ ...
def forward(self): """Generate according to the topological order of the graph.""" self.noise.data.normal_() if not self.confounding: for i in self.topological_order: self.generated[i] = self.blocks[i](th.cat([v for c in [ ...
[ "Generate", "according", "to", "the", "topological", "order", "of", "the", "graph", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/CGNN.py#L111-L125
[ "def", "forward", "(", "self", ")", ":", "self", ".", "noise", ".", "data", ".", "normal_", "(", ")", "if", "not", "self", ".", "confounding", ":", "for", "i", "in", "self", ".", "topological_order", ":", "self", ".", "generated", "[", "i", "]", "=...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
CGNN_model.run
Run the CGNN on a given graph.
cdt/causality/graph/CGNN.py
def run(self, data, train_epochs=1000, test_epochs=1000, verbose=None, idx=0, lr=0.01, **kwargs): """Run the CGNN on a given graph.""" verbose = SETTINGS.get_default(verbose=verbose) optim = th.optim.Adam(self.parameters(), lr=lr) self.score.zero_() with trange(train_...
def run(self, data, train_epochs=1000, test_epochs=1000, verbose=None, idx=0, lr=0.01, **kwargs): """Run the CGNN on a given graph.""" verbose = SETTINGS.get_default(verbose=verbose) optim = th.optim.Adam(self.parameters(), lr=lr) self.score.zero_() with trange(train_...
[ "Run", "the", "CGNN", "on", "a", "given", "graph", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/CGNN.py#L127-L145
[ "def", "run", "(", "self", ",", "data", ",", "train_epochs", "=", "1000", ",", "test_epochs", "=", "1000", ",", "verbose", "=", "None", ",", "idx", "=", "0", ",", "lr", "=", "0.01", ",", "*", "*", "kwargs", ")", ":", "verbose", "=", "SETTINGS", "...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
CGNN.create_graph_from_data
Use CGNN to create a graph from scratch. All the possible structures are tested, which leads to a super exponential complexity. It would be preferable to start from a graph skeleton for large graphs. Args: data (pandas.DataFrame): Observational data on which causal di...
cdt/causality/graph/CGNN.py
def create_graph_from_data(self, data): """Use CGNN to create a graph from scratch. All the possible structures are tested, which leads to a super exponential complexity. It would be preferable to start from a graph skeleton for large graphs. Args: data (pandas.DataFrame): O...
def create_graph_from_data(self, data): """Use CGNN to create a graph from scratch. All the possible structures are tested, which leads to a super exponential complexity. It would be preferable to start from a graph skeleton for large graphs. Args: data (pandas.DataFrame): O...
[ "Use", "CGNN", "to", "create", "a", "graph", "from", "scratch", ".", "All", "the", "possible", "structures", "are", "tested", "which", "leads", "to", "a", "super", "exponential", "complexity", ".", "It", "would", "be", "preferable", "to", "start", "from", ...
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/CGNN.py#L254-L292
[ "def", "create_graph_from_data", "(", "self", ",", "data", ")", ":", "warnings", ".", "warn", "(", "\"An exhaustive search of the causal structure of CGNN without\"", "\" skeleton is super-exponential in the number of variables.\"", ")", "# Building all possible candidates:", "nb_var...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
CGNN.orient_directed_graph
Modify and improve a directed acyclic graph solution using CGNN. Args: data (pandas.DataFrame): Observational data on which causal discovery has to be performed. dag (nx.DiGraph): Graph that provides the initial solution, on which the CGNN algorithm will be...
cdt/causality/graph/CGNN.py
def orient_directed_graph(self, data, dag, alg='HC'): """Modify and improve a directed acyclic graph solution using CGNN. Args: data (pandas.DataFrame): Observational data on which causal discovery has to be performed. dag (nx.DiGraph): Graph that provides the ini...
def orient_directed_graph(self, data, dag, alg='HC'): """Modify and improve a directed acyclic graph solution using CGNN. Args: data (pandas.DataFrame): Observational data on which causal discovery has to be performed. dag (nx.DiGraph): Graph that provides the ini...
[ "Modify", "and", "improve", "a", "directed", "acyclic", "graph", "solution", "using", "CGNN", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/CGNN.py#L294-L313
[ "def", "orient_directed_graph", "(", "self", ",", "data", ",", "dag", ",", "alg", "=", "'HC'", ")", ":", "alg_dic", "=", "{", "'HC'", ":", "hill_climbing", ",", "'HCr'", ":", "hill_climbing_with_removal", ",", "'tabu'", ":", "tabu_search", ",", "'EHC'", ":...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
CGNN.orient_undirected_graph
Orient the undirected graph using GNN and apply CGNN to improve the graph. Args: data (pandas.DataFrame): Observational data on which causal discovery has to be performed. umg (nx.Graph): Graph that provides the skeleton, on which the GNN then the CGNN algo...
cdt/causality/graph/CGNN.py
def orient_undirected_graph(self, data, umg, alg='HC'): """Orient the undirected graph using GNN and apply CGNN to improve the graph. Args: data (pandas.DataFrame): Observational data on which causal discovery has to be performed. umg (nx.Graph): Graph that provid...
def orient_undirected_graph(self, data, umg, alg='HC'): """Orient the undirected graph using GNN and apply CGNN to improve the graph. Args: data (pandas.DataFrame): Observational data on which causal discovery has to be performed. umg (nx.Graph): Graph that provid...
[ "Orient", "the", "undirected", "graph", "using", "GNN", "and", "apply", "CGNN", "to", "improve", "the", "graph", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/CGNN.py#L315-L344
[ "def", "orient_undirected_graph", "(", "self", ",", "data", ",", "umg", ",", "alg", "=", "'HC'", ")", ":", "warnings", ".", "warn", "(", "\"The pairwise GNN model is computed on each edge of the UMG \"", "\"to initialize the model and start CGNN with a DAG\"", ")", "gnn", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
eval_entropy
Evaluate the entropy of the input variable. :param x: input variable 1D :return: entropy of x
cdt/causality/pairwise/IGCI.py
def eval_entropy(x): """Evaluate the entropy of the input variable. :param x: input variable 1D :return: entropy of x """ hx = 0. sx = sorted(x) for i, j in zip(sx[:-1], sx[1:]): delta = j-i if bool(delta): hx += np.log(np.abs(delta)) hx = hx / (len(x) - 1) +...
def eval_entropy(x): """Evaluate the entropy of the input variable. :param x: input variable 1D :return: entropy of x """ hx = 0. sx = sorted(x) for i, j in zip(sx[:-1], sx[1:]): delta = j-i if bool(delta): hx += np.log(np.abs(delta)) hx = hx / (len(x) - 1) +...
[ "Evaluate", "the", "entropy", "of", "the", "input", "variable", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/IGCI.py#L42-L56
[ "def", "eval_entropy", "(", "x", ")", ":", "hx", "=", "0.", "sx", "=", "sorted", "(", "x", ")", "for", "i", ",", "j", "in", "zip", "(", "sx", "[", ":", "-", "1", "]", ",", "sx", "[", "1", ":", "]", ")", ":", "delta", "=", "j", "-", "i",...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
integral_approx_estimator
Integral approximation estimator for causal inference. :param x: input variable x 1D :param y: input variable y 1D :return: Return value of the IGCI model >0 if x->y otherwise if return <0
cdt/causality/pairwise/IGCI.py
def integral_approx_estimator(x, y): """Integral approximation estimator for causal inference. :param x: input variable x 1D :param y: input variable y 1D :return: Return value of the IGCI model >0 if x->y otherwise if return <0 """ a, b = (0., 0.) x = np.array(x) y = np.array(y) id...
def integral_approx_estimator(x, y): """Integral approximation estimator for causal inference. :param x: input variable x 1D :param y: input variable y 1D :return: Return value of the IGCI model >0 if x->y otherwise if return <0 """ a, b = (0., 0.) x = np.array(x) y = np.array(y) id...
[ "Integral", "approximation", "estimator", "for", "causal", "inference", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/IGCI.py#L59-L79
[ "def", "integral_approx_estimator", "(", "x", ",", "y", ")", ":", "a", ",", "b", "=", "(", "0.", ",", "0.", ")", "x", "=", "np", ".", "array", "(", "x", ")", "y", "=", "np", ".", "array", "(", "y", ")", "idx", ",", "idy", "=", "(", "np", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
IGCI.predict_proba
Evaluate a pair using the IGCI model. :param a: Input variable 1D :param b: Input variable 1D :param kwargs: {refMeasure: Scaling method (gaussian, integral or None), estimator: method used to evaluate the pairs (entropy or integral)} :return: Return value of the...
cdt/causality/pairwise/IGCI.py
def predict_proba(self, a, b, **kwargs): """Evaluate a pair using the IGCI model. :param a: Input variable 1D :param b: Input variable 1D :param kwargs: {refMeasure: Scaling method (gaussian, integral or None), estimator: method used to evaluate the pairs (entrop...
def predict_proba(self, a, b, **kwargs): """Evaluate a pair using the IGCI model. :param a: Input variable 1D :param b: Input variable 1D :param kwargs: {refMeasure: Scaling method (gaussian, integral or None), estimator: method used to evaluate the pairs (entrop...
[ "Evaluate", "a", "pair", "using", "the", "IGCI", "model", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/IGCI.py#L96-L115
[ "def", "predict_proba", "(", "self", ",", "a", ",", "b", ",", "*", "*", "kwargs", ")", ":", "estimators", "=", "{", "'entropy'", ":", "lambda", "x", ",", "y", ":", "eval_entropy", "(", "y", ")", "-", "eval_entropy", "(", "x", ")", ",", "'integral'"...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
RCC.featurize_row
Projects the causal pair to the RKHS using the sampled kernel approximation. Args: x (np.ndarray): Variable 1 y (np.ndarray): Variable 2 Returns: np.ndarray: projected empirical distributions into a single fixed-size vector.
cdt/causality/pairwise/RCC.py
def featurize_row(self, x, y): """ Projects the causal pair to the RKHS using the sampled kernel approximation. Args: x (np.ndarray): Variable 1 y (np.ndarray): Variable 2 Returns: np.ndarray: projected empirical distributions into a single fixed-size vector...
def featurize_row(self, x, y): """ Projects the causal pair to the RKHS using the sampled kernel approximation. Args: x (np.ndarray): Variable 1 y (np.ndarray): Variable 2 Returns: np.ndarray: projected empirical distributions into a single fixed-size vector...
[ "Projects", "the", "causal", "pair", "to", "the", "RKHS", "using", "the", "sampled", "kernel", "approximation", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/RCC.py#L75-L95
[ "def", "featurize_row", "(", "self", ",", "x", ",", "y", ")", ":", "x", "=", "x", ".", "ravel", "(", ")", "y", "=", "y", ".", "ravel", "(", ")", "b", "=", "np", ".", "ones", "(", "x", ".", "shape", ")", "dx", "=", "np", ".", "cos", "(", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
RCC.fit
Train the model. Args: x_tr (pd.DataFrame): CEPC format dataframe containing the pairs y_tr (pd.DataFrame or np.ndarray): labels associated to the pairs
cdt/causality/pairwise/RCC.py
def fit(self, x, y): """Train the model. Args: x_tr (pd.DataFrame): CEPC format dataframe containing the pairs y_tr (pd.DataFrame or np.ndarray): labels associated to the pairs """ train = np.vstack((np.array([self.featurize_row(row.iloc[0], ...
def fit(self, x, y): """Train the model. Args: x_tr (pd.DataFrame): CEPC format dataframe containing the pairs y_tr (pd.DataFrame or np.ndarray): labels associated to the pairs """ train = np.vstack((np.array([self.featurize_row(row.iloc[0], ...
[ "Train", "the", "model", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/RCC.py#L97-L114
[ "def", "fit", "(", "self", ",", "x", ",", "y", ")", ":", "train", "=", "np", ".", "vstack", "(", "(", "np", ".", "array", "(", "[", "self", ".", "featurize_row", "(", "row", ".", "iloc", "[", "0", "]", ",", "row", ".", "iloc", "[", "1", "]"...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
RCC.predict_proba
Predict the causal score using a trained RCC model Args: x (numpy.array or pandas.DataFrame or pandas.Series): First variable or dataset. args (numpy.array): second variable (optional depending on the 1st argument). Returns: float: Causation score (Value : 1 if a->b...
cdt/causality/pairwise/RCC.py
def predict_proba(self, x, y=None, **kwargs): """ Predict the causal score using a trained RCC model Args: x (numpy.array or pandas.DataFrame or pandas.Series): First variable or dataset. args (numpy.array): second variable (optional depending on the 1st argument). Retu...
def predict_proba(self, x, y=None, **kwargs): """ Predict the causal score using a trained RCC model Args: x (numpy.array or pandas.DataFrame or pandas.Series): First variable or dataset. args (numpy.array): second variable (optional depending on the 1st argument). Retu...
[ "Predict", "the", "causal", "score", "using", "a", "trained", "RCC", "model" ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/RCC.py#L116-L136
[ "def", "predict_proba", "(", "self", ",", "x", ",", "y", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "clf", "is", "None", ":", "raise", "ValueError", "(", "\"Model has to be trained before making predictions.\"", ")", "if", "x", "is"...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
FSGNN.predict_features
For one variable, predict its neighbours. Args: df_features (pandas.DataFrame): df_target (pandas.Series): nh (int): number of hidden units idx (int): (optional) for printing purposes dropout (float): probability of dropout (between 0 and 1) ...
cdt/independence/graph/FSGNN.py
def predict_features(self, df_features, df_target, nh=20, idx=0, dropout=0., activation_function=th.nn.ReLU, lr=0.01, l1=0.1, batch_size=-1, train_epochs=1000, test_epochs=1000, device=None, verbose=None, nb_runs=3): """For one variable...
def predict_features(self, df_features, df_target, nh=20, idx=0, dropout=0., activation_function=th.nn.ReLU, lr=0.01, l1=0.1, batch_size=-1, train_epochs=1000, test_epochs=1000, device=None, verbose=None, nb_runs=3): """For one variable...
[ "For", "one", "variable", "predict", "its", "neighbours", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/independence/graph/FSGNN.py#L117-L155
[ "def", "predict_features", "(", "self", ",", "df_features", ",", "df_target", ",", "nh", "=", "20", ",", "idx", "=", "0", ",", "dropout", "=", "0.", ",", "activation_function", "=", "th", ".", "nn", ".", "ReLU", ",", "lr", "=", "0.01", ",", "l1", "...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
IndependenceModel.predict_undirected_graph
Build a skeleton using a pairwise independence criterion. Args: data (pandas.DataFrame): Raw data table Returns: networkx.Graph: Undirected graph representing the skeleton.
cdt/independence/stats/model.py
def predict_undirected_graph(self, data): """Build a skeleton using a pairwise independence criterion. Args: data (pandas.DataFrame): Raw data table Returns: networkx.Graph: Undirected graph representing the skeleton. """ graph = Graph() for idx...
def predict_undirected_graph(self, data): """Build a skeleton using a pairwise independence criterion. Args: data (pandas.DataFrame): Raw data table Returns: networkx.Graph: Undirected graph representing the skeleton. """ graph = Graph() for idx...
[ "Build", "a", "skeleton", "using", "a", "pairwise", "independence", "criterion", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/independence/stats/model.py#L57-L74
[ "def", "predict_undirected_graph", "(", "self", ",", "data", ")", ":", "graph", "=", "Graph", "(", ")", "for", "idx_i", ",", "i", "in", "enumerate", "(", "data", ".", "columns", ")", ":", "for", "idx_j", ",", "j", "in", "enumerate", "(", "data", ".",...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
FeatureSelectionModel.run_feature_selection
Run feature selection for one node: wrapper around ``self.predict_features``. Args: df_data (pandas.DataFrame): All the observational data target (str): Name of the target variable idx (int): (optional) For printing purposes Returns: list: scores...
cdt/independence/graph/model.py
def run_feature_selection(self, df_data, target, idx=0, **kwargs): """Run feature selection for one node: wrapper around ``self.predict_features``. Args: df_data (pandas.DataFrame): All the observational data target (str): Name of the target variable idx (int...
def run_feature_selection(self, df_data, target, idx=0, **kwargs): """Run feature selection for one node: wrapper around ``self.predict_features``. Args: df_data (pandas.DataFrame): All the observational data target (str): Name of the target variable idx (int...
[ "Run", "feature", "selection", "for", "one", "node", ":", "wrapper", "around", "self", ".", "predict_features", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/independence/graph/model.py#L83-L100
[ "def", "run_feature_selection", "(", "self", ",", "df_data", ",", "target", ",", "idx", "=", "0", ",", "*", "*", "kwargs", ")", ":", "list_features", "=", "list", "(", "df_data", ".", "columns", ".", "values", ")", "list_features", ".", "remove", "(", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
FeatureSelectionModel.predict
Predict the skeleton of the graph from raw data. Returns iteratively the feature selection algorithm on each node. Args: df_data (pandas.DataFrame): data to construct a graph from threshold (float): cutoff value for feature selection scores kwargs (dict): additional...
cdt/independence/graph/model.py
def predict(self, df_data, threshold=0.05, **kwargs): """Predict the skeleton of the graph from raw data. Returns iteratively the feature selection algorithm on each node. Args: df_data (pandas.DataFrame): data to construct a graph from threshold (float): cutoff value f...
def predict(self, df_data, threshold=0.05, **kwargs): """Predict the skeleton of the graph from raw data. Returns iteratively the feature selection algorithm on each node. Args: df_data (pandas.DataFrame): data to construct a graph from threshold (float): cutoff value f...
[ "Predict", "the", "skeleton", "of", "the", "graph", "from", "raw", "data", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/independence/graph/model.py#L102-L142
[ "def", "predict", "(", "self", ",", "df_data", ",", "threshold", "=", "0.05", ",", "*", "*", "kwargs", ")", ":", "nb_jobs", "=", "kwargs", ".", "get", "(", "\"nb_jobs\"", ",", "SETTINGS", ".", "NB_JOBS", ")", "list_nodes", "=", "list", "(", "df_data", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
GIES.orient_undirected_graph
Run GIES on an undirected graph. Args: data (pandas.DataFrame): DataFrame containing the data graph (networkx.Graph): Skeleton of the graph to orient Returns: networkx.DiGraph: Solution given by the GIES algorithm.
cdt/causality/graph/GIES.py
def orient_undirected_graph(self, data, graph): """Run GIES on an undirected graph. Args: data (pandas.DataFrame): DataFrame containing the data graph (networkx.Graph): Skeleton of the graph to orient Returns: networkx.DiGraph: Solution given by the GIES alg...
def orient_undirected_graph(self, data, graph): """Run GIES on an undirected graph. Args: data (pandas.DataFrame): DataFrame containing the data graph (networkx.Graph): Skeleton of the graph to orient Returns: networkx.DiGraph: Solution given by the GIES alg...
[ "Run", "GIES", "on", "an", "undirected", "graph", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/GIES.py#L91-L112
[ "def", "orient_undirected_graph", "(", "self", ",", "data", ",", "graph", ")", ":", "# Building setup w/ arguments.", "self", ".", "arguments", "[", "'{VERBOSE}'", "]", "=", "str", "(", "self", ".", "verbose", ")", ".", "upper", "(", ")", "self", ".", "arg...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
GIES.create_graph_from_data
Run the GIES algorithm. Args: data (pandas.DataFrame): DataFrame containing the data Returns: networkx.DiGraph: Solution given by the GIES algorithm.
cdt/causality/graph/GIES.py
def create_graph_from_data(self, data): """Run the GIES algorithm. Args: data (pandas.DataFrame): DataFrame containing the data Returns: networkx.DiGraph: Solution given by the GIES algorithm. """ # Building setup w/ arguments. self.arguments['{S...
def create_graph_from_data(self, data): """Run the GIES algorithm. Args: data (pandas.DataFrame): DataFrame containing the data Returns: networkx.DiGraph: Solution given by the GIES algorithm. """ # Building setup w/ arguments. self.arguments['{S...
[ "Run", "the", "GIES", "algorithm", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/GIES.py#L128-L144
[ "def", "create_graph_from_data", "(", "self", ",", "data", ")", ":", "# Building setup w/ arguments.", "self", ".", "arguments", "[", "'{SCORE}'", "]", "=", "self", ".", "scores", "[", "self", ".", "score", "]", "self", ".", "arguments", "[", "'{VERBOSE}'", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
GIES._run_gies
Setting up and running GIES with all arguments.
cdt/causality/graph/GIES.py
def _run_gies(self, data, fixedGaps=None, verbose=True): """Setting up and running GIES with all arguments.""" # Run gies id = str(uuid.uuid4()) os.makedirs('/tmp/cdt_gies' + id + '/') self.arguments['{FOLDER}'] = '/tmp/cdt_gies' + id + '/' def retrieve_result(): ...
def _run_gies(self, data, fixedGaps=None, verbose=True): """Setting up and running GIES with all arguments.""" # Run gies id = str(uuid.uuid4()) os.makedirs('/tmp/cdt_gies' + id + '/') self.arguments['{FOLDER}'] = '/tmp/cdt_gies' + id + '/' def retrieve_result(): ...
[ "Setting", "up", "and", "running", "GIES", "with", "all", "arguments", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/GIES.py#L146-L174
[ "def", "_run_gies", "(", "self", ",", "data", ",", "fixedGaps", "=", "None", ",", "verbose", "=", "True", ")", ":", "# Run gies", "id", "=", "str", "(", "uuid", ".", "uuid4", "(", ")", ")", "os", ".", "makedirs", "(", "'/tmp/cdt_gies'", "+", "id", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
plot_curves
Plot SAM's various losses.
cdt/causality/graph/SAM.py
def plot_curves(i_batch, adv_loss, gen_loss, l1_reg, cols): """Plot SAM's various losses.""" from matplotlib import pyplot as plt if i_batch == 0: try: ax.clear() ax.plot(range(len(adv_plt)), adv_plt, "r-", linewidth=1.5, markersize=4, ...
def plot_curves(i_batch, adv_loss, gen_loss, l1_reg, cols): """Plot SAM's various losses.""" from matplotlib import pyplot as plt if i_batch == 0: try: ax.clear() ax.plot(range(len(adv_plt)), adv_plt, "r-", linewidth=1.5, markersize=4, ...
[ "Plot", "SAM", "s", "various", "losses", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/SAM.py#L187-L224
[ "def", "plot_curves", "(", "i_batch", ",", "adv_loss", ",", "gen_loss", ",", "l1_reg", ",", "cols", ")", ":", "from", "matplotlib", "import", "pyplot", "as", "plt", "if", "i_batch", "==", "0", ":", "try", ":", "ax", ".", "clear", "(", ")", "ax", ".",...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
plot_gen
Plot generated pairs of variables.
cdt/causality/graph/SAM.py
def plot_gen(epoch, batch, generated_variables, pairs_to_plot=[[0, 1]]): """Plot generated pairs of variables.""" from matplotlib import pyplot as plt if epoch == 0: plt.ion() plt.clf() for (i, j) in pairs_to_plot: plt.scatter(generated_variables[i].data.cpu().numpy( ), batc...
def plot_gen(epoch, batch, generated_variables, pairs_to_plot=[[0, 1]]): """Plot generated pairs of variables.""" from matplotlib import pyplot as plt if epoch == 0: plt.ion() plt.clf() for (i, j) in pairs_to_plot: plt.scatter(generated_variables[i].data.cpu().numpy( ), batc...
[ "Plot", "generated", "pairs", "of", "variables", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/SAM.py#L227-L244
[ "def", "plot_gen", "(", "epoch", ",", "batch", ",", "generated_variables", ",", "pairs_to_plot", "=", "[", "[", "0", ",", "1", "]", "]", ")", ":", "from", "matplotlib", "import", "pyplot", "as", "plt", "if", "epoch", "==", "0", ":", "plt", ".", "ion"...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
run_SAM
Execute the SAM model. :param df_data: Input data; either np.array or pd.DataFrame
cdt/causality/graph/SAM.py
def run_SAM(df_data, skeleton=None, **kwargs): """Execute the SAM model. :param df_data: Input data; either np.array or pd.DataFrame """ gpu = kwargs.get('gpu', False) gpu_no = kwargs.get('gpu_no', 0) train_epochs = kwargs.get('train_epochs', 1000) test_epochs = kwargs.get('test_epochs', 1...
def run_SAM(df_data, skeleton=None, **kwargs): """Execute the SAM model. :param df_data: Input data; either np.array or pd.DataFrame """ gpu = kwargs.get('gpu', False) gpu_no = kwargs.get('gpu_no', 0) train_epochs = kwargs.get('train_epochs', 1000) test_epochs = kwargs.get('test_epochs', 1...
[ "Execute", "the", "SAM", "model", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/SAM.py#L247-L387
[ "def", "run_SAM", "(", "df_data", ",", "skeleton", "=", "None", ",", "*", "*", "kwargs", ")", ":", "gpu", "=", "kwargs", ".", "get", "(", "'gpu'", ",", "False", ")", "gpu_no", "=", "kwargs", ".", "get", "(", "'gpu_no'", ",", "0", ")", "train_epochs...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
CNormalized_Linear.reset_parameters
Reset the parameters.
cdt/causality/graph/SAM.py
def reset_parameters(self): """Reset the parameters.""" stdv = 1. / math.sqrt(self.weight.size(1)) self.weight.data.uniform_(-stdv, stdv) if self.bias is not None: self.bias.data.uniform_(-stdv, stdv)
def reset_parameters(self): """Reset the parameters.""" stdv = 1. / math.sqrt(self.weight.size(1)) self.weight.data.uniform_(-stdv, stdv) if self.bias is not None: self.bias.data.uniform_(-stdv, stdv)
[ "Reset", "the", "parameters", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/SAM.py#L54-L59
[ "def", "reset_parameters", "(", "self", ")", ":", "stdv", "=", "1.", "/", "math", ".", "sqrt", "(", "self", ".", "weight", ".", "size", "(", "1", ")", ")", "self", ".", "weight", ".", "data", ".", "uniform_", "(", "-", "stdv", ",", "stdv", ")", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
CNormalized_Linear.forward
Feed-forward through the network.
cdt/causality/graph/SAM.py
def forward(self, input): """Feed-forward through the network.""" return th.nn.functional.linear(input, self.weight.div(self.weight.pow(2).sum(0).sqrt()))
def forward(self, input): """Feed-forward through the network.""" return th.nn.functional.linear(input, self.weight.div(self.weight.pow(2).sum(0).sqrt()))
[ "Feed", "-", "forward", "through", "the", "network", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/SAM.py#L61-L63
[ "def", "forward", "(", "self", ",", "input", ")", ":", "return", "th", ".", "nn", ".", "functional", ".", "linear", "(", "input", ",", "self", ".", "weight", ".", "div", "(", "self", ".", "weight", ".", "pow", "(", "2", ")", ".", "sum", "(", "0...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
SAM_block.forward
Feed-forward the model.
cdt/causality/graph/SAM.py
def forward(self, x): """Feed-forward the model.""" return self.layers(x * (self._filter * self.fs_filter).expand_as(x))
def forward(self, x): """Feed-forward the model.""" return self.layers(x * (self._filter * self.fs_filter).expand_as(x))
[ "Feed", "-", "forward", "the", "model", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/SAM.py#L147-L150
[ "def", "forward", "(", "self", ",", "x", ")", ":", "return", "self", ".", "layers", "(", "x", "*", "(", "self", ".", "_filter", "*", "self", ".", "fs_filter", ")", ".", "expand_as", "(", "x", ")", ")" ]
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
SAM_generators.forward
Feed-forward the model.
cdt/causality/graph/SAM.py
def forward(self, x): """Feed-forward the model.""" for i in self.noise: i.data.normal_() self.generated_variables = [self.blocks[i]( th.cat([x, self.noise[i]], 1)) for i in range(self.cols)] return self.generated_variables
def forward(self, x): """Feed-forward the model.""" for i in self.noise: i.data.normal_() self.generated_variables = [self.blocks[i]( th.cat([x, self.noise[i]], 1)) for i in range(self.cols)] return self.generated_variables
[ "Feed", "-", "forward", "the", "model", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/SAM.py#L177-L184
[ "def", "forward", "(", "self", ",", "x", ")", ":", "for", "i", "in", "self", ".", "noise", ":", "i", ".", "data", ".", "normal_", "(", ")", "self", ".", "generated_variables", "=", "[", "self", ".", "blocks", "[", "i", "]", "(", "th", ".", "cat...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
SAM.predict
Execute SAM on a dataset given a skeleton or not. Args: data (pandas.DataFrame): Observational data for estimation of causal relationships by SAM skeleton (numpy.ndarray): A priori knowledge about the causal relationships as an adjacency matrix. Can be fed either d...
cdt/causality/graph/SAM.py
def predict(self, data, graph=None, nruns=6, njobs=None, gpus=0, verbose=None, plot=False, plot_generated_pair=False, return_list_results=False): """Execute SAM on a dataset given a skeleton or not. Args: data (pandas.DataFrame): Observational data for estimation of causal r...
def predict(self, data, graph=None, nruns=6, njobs=None, gpus=0, verbose=None, plot=False, plot_generated_pair=False, return_list_results=False): """Execute SAM on a dataset given a skeleton or not. Args: data (pandas.DataFrame): Observational data for estimation of causal r...
[ "Execute", "SAM", "on", "a", "dataset", "given", "a", "skeleton", "or", "not", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/SAM.py#L424-L469
[ "def", "predict", "(", "self", ",", "data", ",", "graph", "=", "None", ",", "nruns", "=", "6", ",", "njobs", "=", "None", ",", "gpus", "=", "0", ",", "verbose", "=", "None", ",", "plot", "=", "False", ",", "plot_generated_pair", "=", "False", ",", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
RECI.predict_proba
Infer causal relationships between 2 variables using the RECI statistic :param a: Input variable 1 :param b: Input variable 2 :return: Causation coefficient (Value : 1 if a->b and -1 if b->a) :rtype: float
cdt/causality/pairwise/RECI.py
def predict_proba(self, a, b, **kwargs): """ Infer causal relationships between 2 variables using the RECI statistic :param a: Input variable 1 :param b: Input variable 2 :return: Causation coefficient (Value : 1 if a->b and -1 if b->a) :rtype: float """ return s...
def predict_proba(self, a, b, **kwargs): """ Infer causal relationships between 2 variables using the RECI statistic :param a: Input variable 1 :param b: Input variable 2 :return: Causation coefficient (Value : 1 if a->b and -1 if b->a) :rtype: float """ return s...
[ "Infer", "causal", "relationships", "between", "2", "variables", "using", "the", "RECI", "statistic" ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/RECI.py#L53-L61
[ "def", "predict_proba", "(", "self", ",", "a", ",", "b", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "b_fit_score", "(", "b", ",", "a", ")", "-", "self", ".", "b_fit_score", "(", "a", ",", "b", ")" ]
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
RECI.b_fit_score
Compute the RECI fit score Args: x (numpy.ndarray): Variable 1 y (numpy.ndarray): Variable 2 Returns: float: RECI fit score
cdt/causality/pairwise/RECI.py
def b_fit_score(self, x, y): """ Compute the RECI fit score Args: x (numpy.ndarray): Variable 1 y (numpy.ndarray): Variable 2 Returns: float: RECI fit score """ x = np.reshape(minmax_scale(x), (-1, 1)) y = np.reshape(minmax_scale(y),...
def b_fit_score(self, x, y): """ Compute the RECI fit score Args: x (numpy.ndarray): Variable 1 y (numpy.ndarray): Variable 2 Returns: float: RECI fit score """ x = np.reshape(minmax_scale(x), (-1, 1)) y = np.reshape(minmax_scale(y),...
[ "Compute", "the", "RECI", "fit", "score" ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/RECI.py#L63-L88
[ "def", "b_fit_score", "(", "self", ",", "x", ",", "y", ")", ":", "x", "=", "np", ".", "reshape", "(", "minmax_scale", "(", "x", ")", ",", "(", "-", "1", ",", "1", ")", ")", "y", "=", "np", ".", "reshape", "(", "minmax_scale", "(", "y", ")", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
CDS.predict_proba
Infer causal relationships between 2 variables using the CDS statistic Args: a (numpy.ndarray): Variable 1 b (numpy.ndarray): Variable 2 Returns: float: Causation score (Value : 1 if a->b and -1 if b->a)
cdt/causality/pairwise/CDS.py
def predict_proba(self, a, b, **kwargs): """ Infer causal relationships between 2 variables using the CDS statistic Args: a (numpy.ndarray): Variable 1 b (numpy.ndarray): Variable 2 Returns: float: Causation score (Value : 1 if a->b and -1 if b->a) "...
def predict_proba(self, a, b, **kwargs): """ Infer causal relationships between 2 variables using the CDS statistic Args: a (numpy.ndarray): Variable 1 b (numpy.ndarray): Variable 2 Returns: float: Causation score (Value : 1 if a->b and -1 if b->a) "...
[ "Infer", "causal", "relationships", "between", "2", "variables", "using", "the", "CDS", "statistic" ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/CDS.py#L104-L114
[ "def", "predict_proba", "(", "self", ",", "a", ",", "b", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "cds_score", "(", "b", ",", "a", ")", "-", "self", ".", "cds_score", "(", "a", ",", "b", ")" ]
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
CDS.cds_score
Computes the cds statistic from variable 1 to variable 2 Args: x_te (numpy.ndarray): Variable 1 y_te (numpy.ndarray): Variable 2 Returns: float: CDS fit score
cdt/causality/pairwise/CDS.py
def cds_score(self, x_te, y_te): """ Computes the cds statistic from variable 1 to variable 2 Args: x_te (numpy.ndarray): Variable 1 y_te (numpy.ndarray): Variable 2 Returns: float: CDS fit score """ if type(x_te) == np.ndarray: x...
def cds_score(self, x_te, y_te): """ Computes the cds statistic from variable 1 to variable 2 Args: x_te (numpy.ndarray): Variable 1 y_te (numpy.ndarray): Variable 2 Returns: float: CDS fit score """ if type(x_te) == np.ndarray: x...
[ "Computes", "the", "cds", "statistic", "from", "variable", "1", "to", "variable", "2" ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/CDS.py#L116-L168
[ "def", "cds_score", "(", "self", ",", "x_te", ",", "y_te", ")", ":", "if", "type", "(", "x_te", ")", "==", "np", ".", "ndarray", ":", "x_te", ",", "y_te", "=", "pd", ".", "Series", "(", "x_te", ".", "reshape", "(", "-", "1", ")", ")", ",", "p...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
ANM.predict_proba
Prediction method for pairwise causal inference using the ANM model. Args: a (numpy.ndarray): Variable 1 b (numpy.ndarray): Variable 2 Returns: float: Causation score (Value : 1 if a->b and -1 if b->a)
cdt/causality/pairwise/ANM.py
def predict_proba(self, a, b, **kwargs): """Prediction method for pairwise causal inference using the ANM model. Args: a (numpy.ndarray): Variable 1 b (numpy.ndarray): Variable 2 Returns: float: Causation score (Value : 1 if a->b and -1 if b->a) """ ...
def predict_proba(self, a, b, **kwargs): """Prediction method for pairwise causal inference using the ANM model. Args: a (numpy.ndarray): Variable 1 b (numpy.ndarray): Variable 2 Returns: float: Causation score (Value : 1 if a->b and -1 if b->a) """ ...
[ "Prediction", "method", "for", "pairwise", "causal", "inference", "using", "the", "ANM", "model", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/ANM.py#L134-L147
[ "def", "predict_proba", "(", "self", ",", "a", ",", "b", ",", "*", "*", "kwargs", ")", ":", "a", "=", "scale", "(", "a", ")", ".", "reshape", "(", "(", "-", "1", ",", "1", ")", ")", "b", "=", "scale", "(", "b", ")", ".", "reshape", "(", "...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
ANM.anm_score
Compute the fitness score of the ANM model in the x->y direction. Args: a (numpy.ndarray): Variable seen as cause b (numpy.ndarray): Variable seen as effect Returns: float: ANM fit score
cdt/causality/pairwise/ANM.py
def anm_score(self, x, y): """Compute the fitness score of the ANM model in the x->y direction. Args: a (numpy.ndarray): Variable seen as cause b (numpy.ndarray): Variable seen as effect Returns: float: ANM fit score """ gp = GaussianProcessR...
def anm_score(self, x, y): """Compute the fitness score of the ANM model in the x->y direction. Args: a (numpy.ndarray): Variable seen as cause b (numpy.ndarray): Variable seen as effect Returns: float: ANM fit score """ gp = GaussianProcessR...
[ "Compute", "the", "fitness", "score", "of", "the", "ANM", "model", "in", "the", "x", "-", ">", "y", "direction", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/ANM.py#L149-L163
[ "def", "anm_score", "(", "self", ",", "x", ",", "y", ")", ":", "gp", "=", "GaussianProcessRegressor", "(", ")", ".", "fit", "(", "x", ",", "y", ")", "y_predict", "=", "gp", ".", "predict", "(", "x", ")", "indepscore", "=", "normalized_hsic", "(", "...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
PC.orient_undirected_graph
Run PC on an undirected graph. Args: data (pandas.DataFrame): DataFrame containing the data graph (networkx.Graph): Skeleton of the graph to orient Returns: networkx.DiGraph: Solution given by PC on the given skeleton.
cdt/causality/graph/PC.py
def orient_undirected_graph(self, data, graph, **kwargs): """Run PC on an undirected graph. Args: data (pandas.DataFrame): DataFrame containing the data graph (networkx.Graph): Skeleton of the graph to orient Returns: networkx.DiGraph: Solution given by PC o...
def orient_undirected_graph(self, data, graph, **kwargs): """Run PC on an undirected graph. Args: data (pandas.DataFrame): DataFrame containing the data graph (networkx.Graph): Skeleton of the graph to orient Returns: networkx.DiGraph: Solution given by PC o...
[ "Run", "PC", "on", "an", "undirected", "graph", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/PC.py#L167-L191
[ "def", "orient_undirected_graph", "(", "self", ",", "data", ",", "graph", ",", "*", "*", "kwargs", ")", ":", "# Building setup w/ arguments.", "self", ".", "arguments", "[", "'{CITEST}'", "]", "=", "self", ".", "dir_CI_test", "[", "self", ".", "CI_test", "]"...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
PC.create_graph_from_data
Run the PC algorithm. Args: data (pandas.DataFrame): DataFrame containing the data Returns: networkx.DiGraph: Solution given by PC on the given data.
cdt/causality/graph/PC.py
def create_graph_from_data(self, data, **kwargs): """Run the PC algorithm. Args: data (pandas.DataFrame): DataFrame containing the data Returns: networkx.DiGraph: Solution given by PC on the given data. """ # Building setup w/ arguments. self.argu...
def create_graph_from_data(self, data, **kwargs): """Run the PC algorithm. Args: data (pandas.DataFrame): DataFrame containing the data Returns: networkx.DiGraph: Solution given by PC on the given data. """ # Building setup w/ arguments. self.argu...
[ "Run", "the", "PC", "algorithm", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/PC.py#L211-L231
[ "def", "create_graph_from_data", "(", "self", ",", "data", ",", "*", "*", "kwargs", ")", ":", "# Building setup w/ arguments.", "self", ".", "arguments", "[", "'{CITEST}'", "]", "=", "self", ".", "dir_CI_test", "[", "self", ".", "CI_test", "]", "self", ".", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
PC._run_pc
Setting up and running pc with all arguments.
cdt/causality/graph/PC.py
def _run_pc(self, data, fixedEdges=None, fixedGaps=None, verbose=True): """Setting up and running pc with all arguments.""" # Checking coherence of arguments # print(self.arguments) if (self.arguments['{CITEST}'] == self.dir_CI_test['hsic'] and self.arguments['{METHOD_INDEP}']...
def _run_pc(self, data, fixedEdges=None, fixedGaps=None, verbose=True): """Setting up and running pc with all arguments.""" # Checking coherence of arguments # print(self.arguments) if (self.arguments['{CITEST}'] == self.dir_CI_test['hsic'] and self.arguments['{METHOD_INDEP}']...
[ "Setting", "up", "and", "running", "pc", "with", "all", "arguments", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/PC.py#L233-L276
[ "def", "_run_pc", "(", "self", ",", "data", ",", "fixedEdges", "=", "None", ",", "fixedGaps", "=", "None", ",", "verbose", "=", "True", ")", ":", "# Checking coherence of arguments", "# print(self.arguments)", "if", "(", "self", ".", "arguments", "[", "'{CITES...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
BivariateFit.b_fit_score
Computes the cds statistic from variable 1 to variable 2 Args: a (numpy.ndarray): Variable 1 b (numpy.ndarray): Variable 2 Returns: float: BF fit score
cdt/causality/pairwise/Bivariate_fit.py
def b_fit_score(self, x, y): """ Computes the cds statistic from variable 1 to variable 2 Args: a (numpy.ndarray): Variable 1 b (numpy.ndarray): Variable 2 Returns: float: BF fit score """ x = np.reshape(scale(x), (-1, 1)) y = np.resh...
def b_fit_score(self, x, y): """ Computes the cds statistic from variable 1 to variable 2 Args: a (numpy.ndarray): Variable 1 b (numpy.ndarray): Variable 2 Returns: float: BF fit score """ x = np.reshape(scale(x), (-1, 1)) y = np.resh...
[ "Computes", "the", "cds", "statistic", "from", "variable", "1", "to", "variable", "2" ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/Bivariate_fit.py#L59-L75
[ "def", "b_fit_score", "(", "self", ",", "x", ",", "y", ")", ":", "x", "=", "np", ".", "reshape", "(", "scale", "(", "x", ")", ",", "(", "-", "1", ",", "1", ")", ")", "y", "=", "np", ".", "reshape", "(", "scale", "(", "y", ")", ",", "(", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
Glasso.predict
Predict the graph skeleton. Args: data (pandas.DataFrame): observational data alpha (float): regularization parameter max_iter (int): maximum number of iterations Returns: networkx.Graph: Graph skeleton
cdt/independence/graph/Lasso.py
def predict(self, data, alpha=0.01, max_iter=2000, **kwargs): """ Predict the graph skeleton. Args: data (pandas.DataFrame): observational data alpha (float): regularization parameter max_iter (int): maximum number of iterations Returns: networkx...
def predict(self, data, alpha=0.01, max_iter=2000, **kwargs): """ Predict the graph skeleton. Args: data (pandas.DataFrame): observational data alpha (float): regularization parameter max_iter (int): maximum number of iterations Returns: networkx...
[ "Predict", "the", "graph", "skeleton", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/independence/graph/Lasso.py#L48-L63
[ "def", "predict", "(", "self", ",", "data", ",", "alpha", "=", "0.01", ",", "max_iter", "=", "2000", ",", "*", "*", "kwargs", ")", ":", "edge_model", "=", "GraphLasso", "(", "alpha", "=", "alpha", ",", "max_iter", "=", "max_iter", ")", "edge_model", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
HSICLasso.predict_features
For one variable, predict its neighbouring nodes. Args: df_features (pandas.DataFrame): df_target (pandas.Series): idx (int): (optional) for printing purposes kwargs (dict): additional options for algorithms Returns: list: scores of each feat...
cdt/independence/graph/Lasso.py
def predict_features(self, df_features, df_target, idx=0, **kwargs): """For one variable, predict its neighbouring nodes. Args: df_features (pandas.DataFrame): df_target (pandas.Series): idx (int): (optional) for printing purposes kwargs (dict): additiona...
def predict_features(self, df_features, df_target, idx=0, **kwargs): """For one variable, predict its neighbouring nodes. Args: df_features (pandas.DataFrame): df_target (pandas.Series): idx (int): (optional) for printing purposes kwargs (dict): additiona...
[ "For", "one", "variable", "predict", "its", "neighbouring", "nodes", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/independence/graph/Lasso.py#L71-L92
[ "def", "predict_features", "(", "self", ",", "df_features", ",", "df_target", ",", "idx", "=", "0", ",", "*", "*", "kwargs", ")", ":", "y", "=", "np", ".", "transpose", "(", "df_target", ".", "values", ")", "X", "=", "np", ".", "transpose", "(", "d...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
autoset_settings
Autoset GPU parameters using CUDA_VISIBLE_DEVICES variables. Return default config if variable not set. :param set_var: Variable to set. Must be of type ConfigSettings
cdt/utils/Settings.py
def autoset_settings(set_var): """Autoset GPU parameters using CUDA_VISIBLE_DEVICES variables. Return default config if variable not set. :param set_var: Variable to set. Must be of type ConfigSettings """ try: devices = ast.literal_eval(os.environ["CUDA_VISIBLE_DEVICES"]) if type(d...
def autoset_settings(set_var): """Autoset GPU parameters using CUDA_VISIBLE_DEVICES variables. Return default config if variable not set. :param set_var: Variable to set. Must be of type ConfigSettings """ try: devices = ast.literal_eval(os.environ["CUDA_VISIBLE_DEVICES"]) if type(d...
[ "Autoset", "GPU", "parameters", "using", "CUDA_VISIBLE_DEVICES", "variables", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/utils/Settings.py#L135-L160
[ "def", "autoset_settings", "(", "set_var", ")", ":", "try", ":", "devices", "=", "ast", ".", "literal_eval", "(", "os", ".", "environ", "[", "\"CUDA_VISIBLE_DEVICES\"", "]", ")", "if", "type", "(", "devices", ")", "!=", "list", "and", "type", "(", "devic...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
check_cuda_devices
Output some information on CUDA-enabled devices on your computer, including current memory usage. Modified to only get number of devices. It's a port of https://gist.github.com/f0k/0d6431e3faa60bffc788f8b4daa029b1 from C to Python with ctypes, so it can run without compiling anything. Note that this is...
cdt/utils/Settings.py
def check_cuda_devices(): """Output some information on CUDA-enabled devices on your computer, including current memory usage. Modified to only get number of devices. It's a port of https://gist.github.com/f0k/0d6431e3faa60bffc788f8b4daa029b1 from C to Python with ctypes, so it can run without compilin...
def check_cuda_devices(): """Output some information on CUDA-enabled devices on your computer, including current memory usage. Modified to only get number of devices. It's a port of https://gist.github.com/f0k/0d6431e3faa60bffc788f8b4daa029b1 from C to Python with ctypes, so it can run without compilin...
[ "Output", "some", "information", "on", "CUDA", "-", "enabled", "devices", "on", "your", "computer", "including", "current", "memory", "usage", ".", "Modified", "to", "only", "get", "number", "of", "devices", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/utils/Settings.py#L163-L208
[ "def", "check_cuda_devices", "(", ")", ":", "import", "ctypes", "# Some constants taken from cuda.h", "CUDA_SUCCESS", "=", "0", "libnames", "=", "(", "'libcuda.so'", ",", "'libcuda.dylib'", ",", "'cuda.dll'", ")", "for", "libname", "in", "libnames", ":", "try", ":...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
ConfigSettings.get_default
Get the default parameters as defined in the Settings instance. This function proceeds to seamlessly retrieve the argument to pass through, depending on either it was overidden or not: If no argument was overridden in a function of the toolbox, the default argument will be set to ``None...
cdt/utils/Settings.py
def get_default(self, *args, **kwargs): """Get the default parameters as defined in the Settings instance. This function proceeds to seamlessly retrieve the argument to pass through, depending on either it was overidden or not: If no argument was overridden in a function of the toolbox,...
def get_default(self, *args, **kwargs): """Get the default parameters as defined in the Settings instance. This function proceeds to seamlessly retrieve the argument to pass through, depending on either it was overidden or not: If no argument was overridden in a function of the toolbox,...
[ "Get", "the", "default", "parameters", "as", "defined", "in", "the", "Settings", "instance", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/utils/Settings.py#L95-L132
[ "def", "get_default", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "retrieve_param", "(", "i", ")", ":", "try", ":", "return", "self", ".", "__getattribute__", "(", "i", ")", "except", "AttributeError", ":", "if", "i", "==...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
read_causal_pairs
Convert a ChaLearn Cause effect pairs challenge format into numpy.ndarray. :param filename: path of the file to read or DataFrame containing the data :type filename: str or pandas.DataFrame :param scale: Scale the data :type scale: bool :param kwargs: parameters to be passed to pandas.read_csv ...
cdt/utils/io.py
def read_causal_pairs(filename, scale=True, **kwargs): """Convert a ChaLearn Cause effect pairs challenge format into numpy.ndarray. :param filename: path of the file to read or DataFrame containing the data :type filename: str or pandas.DataFrame :param scale: Scale the data :type scale: bool ...
def read_causal_pairs(filename, scale=True, **kwargs): """Convert a ChaLearn Cause effect pairs challenge format into numpy.ndarray. :param filename: path of the file to read or DataFrame containing the data :type filename: str or pandas.DataFrame :param scale: Scale the data :type scale: bool ...
[ "Convert", "a", "ChaLearn", "Cause", "effect", "pairs", "challenge", "format", "into", "numpy", ".", "ndarray", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/utils/io.py#L34-L81
[ "def", "read_causal_pairs", "(", "filename", ",", "scale", "=", "True", ",", "*", "*", "kwargs", ")", ":", "def", "convert_row", "(", "row", ",", "scale", ")", ":", "\"\"\"Convert a CCEPC row into numpy.ndarrays.\n\n :param row:\n :type row: pandas.Series\n ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
read_adjacency_matrix
Read a file (containing an adjacency matrix) and convert it into a directed or undirected networkx graph. :param filename: file to read or DataFrame containing the data :type filename: str or pandas.DataFrame :param directed: Return directed graph :type directed: bool :param kwargs: extra param...
cdt/utils/io.py
def read_adjacency_matrix(filename, directed=True, **kwargs): """Read a file (containing an adjacency matrix) and convert it into a directed or undirected networkx graph. :param filename: file to read or DataFrame containing the data :type filename: str or pandas.DataFrame :param directed: Return d...
def read_adjacency_matrix(filename, directed=True, **kwargs): """Read a file (containing an adjacency matrix) and convert it into a directed or undirected networkx graph. :param filename: file to read or DataFrame containing the data :type filename: str or pandas.DataFrame :param directed: Return d...
[ "Read", "a", "file", "(", "containing", "an", "adjacency", "matrix", ")", "and", "convert", "it", "into", "a", "directed", "or", "undirected", "networkx", "graph", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/utils/io.py#L84-L108
[ "def", "read_adjacency_matrix", "(", "filename", ",", "directed", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "filename", ",", "str", ")", ":", "data", "=", "read_csv", "(", "filename", ",", "*", "*", "kwargs", ")", "elif",...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
read_list_edges
Read a file (containing list of edges) and convert it into a directed or undirected networkx graph. :param filename: file to read or DataFrame containing the data :type filename: str or pandas.DataFrame :param directed: Return directed graph :type directed: bool :param kwargs: extra parameters ...
cdt/utils/io.py
def read_list_edges(filename, directed=True, **kwargs): """Read a file (containing list of edges) and convert it into a directed or undirected networkx graph. :param filename: file to read or DataFrame containing the data :type filename: str or pandas.DataFrame :param directed: Return directed grap...
def read_list_edges(filename, directed=True, **kwargs): """Read a file (containing list of edges) and convert it into a directed or undirected networkx graph. :param filename: file to read or DataFrame containing the data :type filename: str or pandas.DataFrame :param directed: Return directed grap...
[ "Read", "a", "file", "(", "containing", "list", "of", "edges", ")", "and", "convert", "it", "into", "a", "directed", "or", "undirected", "networkx", "graph", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/utils/io.py#L111-L143
[ "def", "read_list_edges", "(", "filename", ",", "directed", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "filename", ",", "str", ")", ":", "data", "=", "read_csv", "(", "filename", ",", "*", "*", "kwargs", ")", "elif", "is...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
MomentMatchingLoss.forward
Compute the loss model. :param pred: predicted Variable :param target: Target Variable :return: Loss
cdt/utils/loss.py
def forward(self, pred, target): """Compute the loss model. :param pred: predicted Variable :param target: Target Variable :return: Loss """ loss = th.FloatTensor([0]) for i in range(1, self.moments): mk_pred = th.mean(th.pow(pred, i), 0) ...
def forward(self, pred, target): """Compute the loss model. :param pred: predicted Variable :param target: Target Variable :return: Loss """ loss = th.FloatTensor([0]) for i in range(1, self.moments): mk_pred = th.mean(th.pow(pred, i), 0) ...
[ "Compute", "the", "loss", "model", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/utils/loss.py#L177-L191
[ "def", "forward", "(", "self", ",", "pred", ",", "target", ")", ":", "loss", "=", "th", ".", "FloatTensor", "(", "[", "0", "]", ")", "for", "i", "in", "range", "(", "1", ",", "self", ".", "moments", ")", ":", "mk_pred", "=", "th", ".", "mean", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
MIRegression.predict
Compute the test statistic Args: a (array-like): Variable 1 b (array-like): Variable 2 Returns: float: test statistic
cdt/independence/stats/numerical.py
def predict(self, a, b): """ Compute the test statistic Args: a (array-like): Variable 1 b (array-like): Variable 2 Returns: float: test statistic """ a = np.array(a).reshape((-1, 1)) b = np.array(b).reshape((-1, 1)) return (m...
def predict(self, a, b): """ Compute the test statistic Args: a (array-like): Variable 1 b (array-like): Variable 2 Returns: float: test statistic """ a = np.array(a).reshape((-1, 1)) b = np.array(b).reshape((-1, 1)) return (m...
[ "Compute", "the", "test", "statistic" ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/independence/stats/numerical.py#L156-L168
[ "def", "predict", "(", "self", ",", "a", ",", "b", ")", ":", "a", "=", "np", ".", "array", "(", "a", ")", ".", "reshape", "(", "(", "-", "1", ",", "1", ")", ")", "b", "=", "np", ".", "array", "(", "b", ")", ".", "reshape", "(", "(", "-"...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
KendallTau.predict
Compute the test statistic Args: a (array-like): Variable 1 b (array-like): Variable 2 Returns: float: test statistic
cdt/independence/stats/numerical.py
def predict(self, a, b): """ Compute the test statistic Args: a (array-like): Variable 1 b (array-like): Variable 2 Returns: float: test statistic """ a = np.array(a).reshape((-1, 1)) b = np.array(b).reshape((-1, 1)) return sp...
def predict(self, a, b): """ Compute the test statistic Args: a (array-like): Variable 1 b (array-like): Variable 2 Returns: float: test statistic """ a = np.array(a).reshape((-1, 1)) b = np.array(b).reshape((-1, 1)) return sp...
[ "Compute", "the", "test", "statistic" ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/independence/stats/numerical.py#L176-L188
[ "def", "predict", "(", "self", ",", "a", ",", "b", ")", ":", "a", "=", "np", ".", "array", "(", "a", ")", ".", "reshape", "(", "(", "-", "1", ",", "1", ")", ")", "b", "=", "np", ".", "array", "(", "b", ")", ".", "reshape", "(", "(", "-"...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
NormalizedHSIC.predict
Compute the test statistic Args: a (array-like): Variable 1 b (array-like): Variable 2 sig (list): [0] (resp [1]) is kernel size for a(resp b) (set to median distance if -1) maxpnt (int): maximum number of points used, for computational time Returns: ...
cdt/independence/stats/numerical.py
def predict(self, a, b, sig=[-1, -1], maxpnt=500): """ Compute the test statistic Args: a (array-like): Variable 1 b (array-like): Variable 2 sig (list): [0] (resp [1]) is kernel size for a(resp b) (set to median distance if -1) maxpnt (int): maximum numb...
def predict(self, a, b, sig=[-1, -1], maxpnt=500): """ Compute the test statistic Args: a (array-like): Variable 1 b (array-like): Variable 2 sig (list): [0] (resp [1]) is kernel size for a(resp b) (set to median distance if -1) maxpnt (int): maximum numb...
[ "Compute", "the", "test", "statistic" ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/independence/stats/numerical.py#L196-L211
[ "def", "predict", "(", "self", ",", "a", ",", "b", ",", "sig", "=", "[", "-", "1", ",", "-", "1", "]", ",", "maxpnt", "=", "500", ")", ":", "a", "=", "(", "a", "-", "np", ".", "mean", "(", "a", ")", ")", "/", "np", ".", "std", "(", "a...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
PairwiseModel.predict
Generic predict method, chooses which subfunction to use for a more suited. Depending on the type of `x` and of `*args`, this function process to execute different functions in the priority order: 1. If ``args[0]`` is a ``networkx.(Di)Graph``, then ``self.orient_graph`` is executed. ...
cdt/causality/pairwise/model.py
def predict(self, x, *args, **kwargs): """Generic predict method, chooses which subfunction to use for a more suited. Depending on the type of `x` and of `*args`, this function process to execute different functions in the priority order: 1. If ``args[0]`` is a ``networkx.(Di)G...
def predict(self, x, *args, **kwargs): """Generic predict method, chooses which subfunction to use for a more suited. Depending on the type of `x` and of `*args`, this function process to execute different functions in the priority order: 1. If ``args[0]`` is a ``networkx.(Di)G...
[ "Generic", "predict", "method", "chooses", "which", "subfunction", "to", "use", "for", "a", "more", "suited", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/model.py#L44-L71
[ "def", "predict", "(", "self", ",", "x", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "args", ")", ">", "0", ":", "if", "type", "(", "args", "[", "0", "]", ")", "==", "nx", ".", "Graph", "or", "type", "(", "args", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
PairwiseModel.predict_dataset
Generic dataset prediction function. Runs the score independently on all pairs. Args: x (pandas.DataFrame): a CEPC format Dataframe. kwargs (dict): additional arguments for the algorithms Returns: pandas.DataFrame: a Dataframe with the predictions.
cdt/causality/pairwise/model.py
def predict_dataset(self, x, **kwargs): """Generic dataset prediction function. Runs the score independently on all pairs. Args: x (pandas.DataFrame): a CEPC format Dataframe. kwargs (dict): additional arguments for the algorithms Returns: pandas.Da...
def predict_dataset(self, x, **kwargs): """Generic dataset prediction function. Runs the score independently on all pairs. Args: x (pandas.DataFrame): a CEPC format Dataframe. kwargs (dict): additional arguments for the algorithms Returns: pandas.Da...
[ "Generic", "dataset", "prediction", "function", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/model.py#L88-L114
[ "def", "predict_dataset", "(", "self", ",", "x", ",", "*", "*", "kwargs", ")", ":", "printout", "=", "kwargs", ".", "get", "(", "\"printout\"", ",", "None", ")", "pred", "=", "[", "]", "res", "=", "[", "]", "x", ".", "columns", "=", "[", "\"A\"",...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
PairwiseModel.orient_graph
Orient an undirected graph using the pairwise method defined by the subclass. The pairwise method is ran on every undirected edge. Args: df_data (pandas.DataFrame): Data umg (networkx.Graph): Graph to orient nb_runs (int): number of times to rerun for each pair (boo...
cdt/causality/pairwise/model.py
def orient_graph(self, df_data, graph, nb_runs=6, printout=None, **kwargs): """Orient an undirected graph using the pairwise method defined by the subclass. The pairwise method is ran on every undirected edge. Args: df_data (pandas.DataFrame): Data umg (networkx.Graph):...
def orient_graph(self, df_data, graph, nb_runs=6, printout=None, **kwargs): """Orient an undirected graph using the pairwise method defined by the subclass. The pairwise method is ran on every undirected edge. Args: df_data (pandas.DataFrame): Data umg (networkx.Graph):...
[ "Orient", "an", "undirected", "graph", "using", "the", "pairwise", "method", "defined", "by", "the", "subclass", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/model.py#L116-L170
[ "def", "orient_graph", "(", "self", ",", "df_data", ",", "graph", ",", "nb_runs", "=", "6", ",", "printout", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "type", "(", "graph", ")", "==", "nx", ".", "DiGraph", ":", "edges", "=", "[", "a",...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
BNlearnAlgorithm.orient_undirected_graph
Run the algorithm on an undirected graph. Args: data (pandas.DataFrame): DataFrame containing the data graph (networkx.Graph): Skeleton of the graph to orient Returns: networkx.DiGraph: Solution on the given skeleton.
cdt/causality/graph/bnlearn.py
def orient_undirected_graph(self, data, graph): """Run the algorithm on an undirected graph. Args: data (pandas.DataFrame): DataFrame containing the data graph (networkx.Graph): Skeleton of the graph to orient Returns: networkx.DiGraph: Solution on the given...
def orient_undirected_graph(self, data, graph): """Run the algorithm on an undirected graph. Args: data (pandas.DataFrame): DataFrame containing the data graph (networkx.Graph): Skeleton of the graph to orient Returns: networkx.DiGraph: Solution on the given...
[ "Run", "the", "algorithm", "on", "an", "undirected", "graph", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/bnlearn.py#L140-L166
[ "def", "orient_undirected_graph", "(", "self", ",", "data", ",", "graph", ")", ":", "# Building setup w/ arguments.", "self", ".", "arguments", "[", "'{VERBOSE}'", "]", "=", "str", "(", "self", ".", "verbose", ")", ".", "upper", "(", ")", "self", ".", "arg...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
BNlearnAlgorithm.orient_directed_graph
Run the algorithm on a directed_graph. Args: data (pandas.DataFrame): DataFrame containing the data graph (networkx.DiGraph): Skeleton of the graph to orient Returns: networkx.DiGraph: Solution on the given skeleton. .. warning:: The algorithm is...
cdt/causality/graph/bnlearn.py
def orient_directed_graph(self, data, graph): """Run the algorithm on a directed_graph. Args: data (pandas.DataFrame): DataFrame containing the data graph (networkx.DiGraph): Skeleton of the graph to orient Returns: networkx.DiGraph: Solution on the given sk...
def orient_directed_graph(self, data, graph): """Run the algorithm on a directed_graph. Args: data (pandas.DataFrame): DataFrame containing the data graph (networkx.DiGraph): Skeleton of the graph to orient Returns: networkx.DiGraph: Solution on the given sk...
[ "Run", "the", "algorithm", "on", "a", "directed_graph", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/bnlearn.py#L168-L183
[ "def", "orient_directed_graph", "(", "self", ",", "data", ",", "graph", ")", ":", "warnings", ".", "warn", "(", "\"The algorithm is ran on the skeleton of the given graph.\"", ")", "return", "self", ".", "orient_undirected_graph", "(", "data", ",", "nx", ".", "Graph...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
BNlearnAlgorithm.create_graph_from_data
Run the algorithm on data. Args: data (pandas.DataFrame): DataFrame containing the data Returns: networkx.DiGraph: Solution given by the algorithm.
cdt/causality/graph/bnlearn.py
def create_graph_from_data(self, data): """Run the algorithm on data. Args: data (pandas.DataFrame): DataFrame containing the data Returns: networkx.DiGraph: Solution given by the algorithm. """ # Building setup w/ arguments. self.arguments['{SC...
def create_graph_from_data(self, data): """Run the algorithm on data. Args: data (pandas.DataFrame): DataFrame containing the data Returns: networkx.DiGraph: Solution given by the algorithm. """ # Building setup w/ arguments. self.arguments['{SC...
[ "Run", "the", "algorithm", "on", "data", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/bnlearn.py#L185-L205
[ "def", "create_graph_from_data", "(", "self", ",", "data", ")", ":", "# Building setup w/ arguments.", "self", ".", "arguments", "[", "'{SCORE}'", "]", "=", "self", ".", "score", "self", ".", "arguments", "[", "'{VERBOSE}'", "]", "=", "str", "(", "self", "."...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
computeGaussKernel
Compute the gaussian kernel on a 1D vector.
cdt/generators/causal_mechanisms.py
def computeGaussKernel(x): """Compute the gaussian kernel on a 1D vector.""" xnorm = np.power(euclidean_distances(x, x), 2) return np.exp(-xnorm / (2.0))
def computeGaussKernel(x): """Compute the gaussian kernel on a 1D vector.""" xnorm = np.power(euclidean_distances(x, x), 2) return np.exp(-xnorm / (2.0))
[ "Compute", "the", "gaussian", "kernel", "on", "a", "1D", "vector", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/generators/causal_mechanisms.py#L186-L189
[ "def", "computeGaussKernel", "(", "x", ")", ":", "xnorm", "=", "np", ".", "power", "(", "euclidean_distances", "(", "x", ",", "x", ")", ",", "2", ")", "return", "np", ".", "exp", "(", "-", "xnorm", "/", "(", "2.0", ")", ")" ]
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
gmm_cause
Init a root cause with a Gaussian Mixture Model w/ a spherical covariance type.
cdt/generators/causal_mechanisms.py
def gmm_cause(points, k=4, p1=2, p2=2): """Init a root cause with a Gaussian Mixture Model w/ a spherical covariance type.""" g = GMM(k, covariance_type="spherical") g.fit(np.random.randn(300, 1)) g.means_ = p1 * np.random.randn(k, 1) g.covars_ = np.power(abs(p2 * np.random.randn(k, 1) + 1), 2) ...
def gmm_cause(points, k=4, p1=2, p2=2): """Init a root cause with a Gaussian Mixture Model w/ a spherical covariance type.""" g = GMM(k, covariance_type="spherical") g.fit(np.random.randn(300, 1)) g.means_ = p1 * np.random.randn(k, 1) g.covars_ = np.power(abs(p2 * np.random.randn(k, 1) + 1), 2) ...
[ "Init", "a", "root", "cause", "with", "a", "Gaussian", "Mixture", "Model", "w", "/", "a", "spherical", "covariance", "type", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/generators/causal_mechanisms.py#L321-L330
[ "def", "gmm_cause", "(", "points", ",", "k", "=", "4", ",", "p1", "=", "2", ",", "p2", "=", "2", ")", ":", "g", "=", "GMM", "(", "k", ",", "covariance_type", "=", "\"spherical\"", ")", "g", ".", "fit", "(", "np", ".", "random", ".", "randn", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
normal_noise
Init a noise variable.
cdt/generators/causal_mechanisms.py
def normal_noise(points): """Init a noise variable.""" return np.random.rand(1) * np.random.randn(points, 1) \ + random.sample([2, -2], 1)
def normal_noise(points): """Init a noise variable.""" return np.random.rand(1) * np.random.randn(points, 1) \ + random.sample([2, -2], 1)
[ "Init", "a", "noise", "variable", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/generators/causal_mechanisms.py#L338-L341
[ "def", "normal_noise", "(", "points", ")", ":", "return", "np", ".", "random", ".", "rand", "(", "1", ")", "*", "np", ".", "random", ".", "randn", "(", "points", ",", "1", ")", "+", "random", ".", "sample", "(", "[", "2", ",", "-", "2", "]", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
uniform_noise
Init a uniform noise variable.
cdt/generators/causal_mechanisms.py
def uniform_noise(points): """Init a uniform noise variable.""" return np.random.rand(1) * np.random.uniform(points, 1) \ + random.sample([2, -2], 1)
def uniform_noise(points): """Init a uniform noise variable.""" return np.random.rand(1) * np.random.uniform(points, 1) \ + random.sample([2, -2], 1)
[ "Init", "a", "uniform", "noise", "variable", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/generators/causal_mechanisms.py#L344-L347
[ "def", "uniform_noise", "(", "points", ")", ":", "return", "np", ".", "random", ".", "rand", "(", "1", ")", "*", "np", ".", "random", ".", "uniform", "(", "points", ",", "1", ")", "+", "random", ".", "sample", "(", "[", "2", ",", "-", "2", "]",...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
SigmoidAM_Mechanism.mechanism
Mechanism function.
cdt/generators/causal_mechanisms.py
def mechanism(self, x): """Mechanism function.""" result = np.\ zeros((self.points, 1)) for i in range(self.points): result[i, 0] = self.a * self.b * (x[i] + self.c) / (1 + abs(self.b * (x[i] + self.c))) return result + self.noise
def mechanism(self, x): """Mechanism function.""" result = np.\ zeros((self.points, 1)) for i in range(self.points): result[i, 0] = self.a * self.b * (x[i] + self.c) / (1 + abs(self.b * (x[i] + self.c))) return result + self.noise
[ "Mechanism", "function", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/generators/causal_mechanisms.py#L79-L87
[ "def", "mechanism", "(", "self", ",", "x", ")", ":", "result", "=", "np", ".", "zeros", "(", "(", "self", ".", "points", ",", "1", ")", ")", "for", "i", "in", "range", "(", "self", ".", "points", ")", ":", "result", "[", "i", ",", "0", "]", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
SigmoidMix_Mechanism.mechanism
Mechanism function.
cdt/generators/causal_mechanisms.py
def mechanism(self, causes): """Mechanism function.""" result = np.zeros((self.points, 1)) for i in range(self.points): pre_add_effect = 0 for c in range(causes.shape[1]): pre_add_effect += causes[i, c] pre_add_effect += self.noise[i] ...
def mechanism(self, causes): """Mechanism function.""" result = np.zeros((self.points, 1)) for i in range(self.points): pre_add_effect = 0 for c in range(causes.shape[1]): pre_add_effect += causes[i, c] pre_add_effect += self.noise[i] ...
[ "Mechanism", "function", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/generators/causal_mechanisms.py#L117-L129
[ "def", "mechanism", "(", "self", ",", "causes", ")", ":", "result", "=", "np", ".", "zeros", "(", "(", "self", ".", "points", ",", "1", ")", ")", "for", "i", "in", "range", "(", "self", ".", "points", ")", ":", "pre_add_effect", "=", "0", "for", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
Polynomial_Mechanism.mechanism
Mechanism function.
cdt/generators/causal_mechanisms.py
def mechanism(self, x, par): """Mechanism function.""" list_coeff = self.polycause[par] result = np.zeros((self.points, 1)) for i in range(self.points): for j in range(self.d+1): result[i, 0] += list_coeff[j]*np.power(x[i], j) result[i, 0] = min(re...
def mechanism(self, x, par): """Mechanism function.""" list_coeff = self.polycause[par] result = np.zeros((self.points, 1)) for i in range(self.points): for j in range(self.d+1): result[i, 0] += list_coeff[j]*np.power(x[i], j) result[i, 0] = min(re...
[ "Mechanism", "function", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/generators/causal_mechanisms.py#L159-L169
[ "def", "mechanism", "(", "self", ",", "x", ",", "par", ")", ":", "list_coeff", "=", "self", ".", "polycause", "[", "par", "]", "result", "=", "np", ".", "zeros", "(", "(", "self", ".", "points", ",", "1", ")", ")", "for", "i", "in", "range", "(...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
GaussianProcessAdd_Mechanism.mechanism
Mechanism function.
cdt/generators/causal_mechanisms.py
def mechanism(self, x): """Mechanism function.""" self.nb_step += 1 x = np.reshape(x, (x.shape[0], 1)) if(self.nb_step < 5): cov = computeGaussKernel(x) mean = np.zeros((1, self.points))[0, :] y = np.random.multivariate_normal(mean, cov) elif(...
def mechanism(self, x): """Mechanism function.""" self.nb_step += 1 x = np.reshape(x, (x.shape[0], 1)) if(self.nb_step < 5): cov = computeGaussKernel(x) mean = np.zeros((1, self.points))[0, :] y = np.random.multivariate_normal(mean, cov) elif(...
[ "Mechanism", "function", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/generators/causal_mechanisms.py#L203-L222
[ "def", "mechanism", "(", "self", ",", "x", ")", ":", "self", ".", "nb_step", "+=", "1", "x", "=", "np", ".", "reshape", "(", "x", ",", "(", "x", ".", "shape", "[", "0", "]", ",", "1", ")", ")", "if", "(", "self", ".", "nb_step", "<", "5", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
NN_Mechanism.mechanism
Mechanism function.
cdt/generators/causal_mechanisms.py
def mechanism(self, x): """Mechanism function.""" layers = [] layers.append(th.nn.modules.Linear(self.n_causes+1, self.nh)) layers.append(th.nn.Tanh()) layers.append(th.nn.modules.Linear(self.nh, 1)) self.layers = th.nn.Sequential(*layers) data = x.astype('floa...
def mechanism(self, x): """Mechanism function.""" layers = [] layers.append(th.nn.modules.Linear(self.n_causes+1, self.nh)) layers.append(th.nn.Tanh()) layers.append(th.nn.modules.Linear(self.nh, 1)) self.layers = th.nn.Sequential(*layers) data = x.astype('floa...
[ "Mechanism", "function", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/generators/causal_mechanisms.py#L293-L306
[ "def", "mechanism", "(", "self", ",", "x", ")", ":", "layers", "=", "[", "]", "layers", ".", "append", "(", "th", ".", "nn", ".", "modules", ".", "Linear", "(", "self", ".", "n_causes", "+", "1", ",", "self", ".", "nh", ")", ")", "layers", ".",...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
Jarfo.predict_dataset
Runs Jarfo independently on all pairs. Args: x (pandas.DataFrame): a CEPC format Dataframe. kwargs (dict): additional arguments for the algorithms Returns: pandas.DataFrame: a Dataframe with the predictions.
cdt/causality/pairwise/Jarfo.py
def predict_dataset(self, df): """Runs Jarfo independently on all pairs. Args: x (pandas.DataFrame): a CEPC format Dataframe. kwargs (dict): additional arguments for the algorithms Returns: pandas.DataFrame: a Dataframe with the predictions. """ ...
def predict_dataset(self, df): """Runs Jarfo independently on all pairs. Args: x (pandas.DataFrame): a CEPC format Dataframe. kwargs (dict): additional arguments for the algorithms Returns: pandas.DataFrame: a Dataframe with the predictions. """ ...
[ "Runs", "Jarfo", "independently", "on", "all", "pairs", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/Jarfo.py#L59-L78
[ "def", "predict_dataset", "(", "self", ",", "df", ")", ":", "if", "len", "(", "list", "(", "df", ".", "columns", ")", ")", "==", "2", ":", "df", ".", "columns", "=", "[", "\"A\"", ",", "\"B\"", "]", "if", "self", ".", "model", "is", "None", ":"...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
Jarfo.predict_proba
Use Jarfo to predict the causal direction of a pair of vars. Args: a (numpy.ndarray): Variable 1 b (numpy.ndarray): Variable 2 idx (int): (optional) index number for printing purposes Returns: float: Causation score (Value : 1 if a->b and -1 if b->a)
cdt/causality/pairwise/Jarfo.py
def predict_proba(self, a, b, idx=0, **kwargs): """ Use Jarfo to predict the causal direction of a pair of vars. Args: a (numpy.ndarray): Variable 1 b (numpy.ndarray): Variable 2 idx (int): (optional) index number for printing purposes Returns: f...
def predict_proba(self, a, b, idx=0, **kwargs): """ Use Jarfo to predict the causal direction of a pair of vars. Args: a (numpy.ndarray): Variable 1 b (numpy.ndarray): Variable 2 idx (int): (optional) index number for printing purposes Returns: f...
[ "Use", "Jarfo", "to", "predict", "the", "causal", "direction", "of", "a", "pair", "of", "vars", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/Jarfo.py#L80-L92
[ "def", "predict_proba", "(", "self", ",", "a", ",", "b", ",", "idx", "=", "0", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "predict_dataset", "(", "DataFrame", "(", "[", "[", "a", ",", "b", "]", "]", ",", "columns", "=", "[", "'A'...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
network_deconvolution
Python implementation/translation of network deconvolution by MIT-KELLIS LAB. .. note:: code author:gidonro [Github username](https://github.com/gidonro/Network-Deconvolution) LICENSE: MIT-KELLIS LAB AUTHORS: Algorithm was programmed by Soheil Feizi. Paper authors are S. Feizi,...
cdt/utils/graph.py
def network_deconvolution(mat, **kwargs): """Python implementation/translation of network deconvolution by MIT-KELLIS LAB. .. note:: code author:gidonro [Github username](https://github.com/gidonro/Network-Deconvolution) LICENSE: MIT-KELLIS LAB AUTHORS: Algorithm was programmed by...
def network_deconvolution(mat, **kwargs): """Python implementation/translation of network deconvolution by MIT-KELLIS LAB. .. note:: code author:gidonro [Github username](https://github.com/gidonro/Network-Deconvolution) LICENSE: MIT-KELLIS LAB AUTHORS: Algorithm was programmed by...
[ "Python", "implementation", "/", "translation", "of", "network", "deconvolution", "by", "MIT", "-", "KELLIS", "LAB", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/utils/graph.py#L35-L136
[ "def", "network_deconvolution", "(", "mat", ",", "*", "*", "kwargs", ")", ":", "alpha", "=", "kwargs", ".", "get", "(", "'alpha'", ",", "1", ")", "beta", "=", "kwargs", ".", "get", "(", "'beta'", ",", "0.99", ")", "control", "=", "kwargs", ".", "ge...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
clr
Implementation of the Context Likelihood or Relatedness Network algorithm. Args: mat (numpy.ndarray): matrix, if it is a square matrix, the program assumes it is a relevance matrix where mat(i,j) represents the similarity content between nodes i and j. Elements of matrix should be n...
cdt/utils/graph.py
def clr(M, **kwargs): """Implementation of the Context Likelihood or Relatedness Network algorithm. Args: mat (numpy.ndarray): matrix, if it is a square matrix, the program assumes it is a relevance matrix where mat(i,j) represents the similarity content between nodes i and j. Elements o...
def clr(M, **kwargs): """Implementation of the Context Likelihood or Relatedness Network algorithm. Args: mat (numpy.ndarray): matrix, if it is a square matrix, the program assumes it is a relevance matrix where mat(i,j) represents the similarity content between nodes i and j. Elements o...
[ "Implementation", "of", "the", "Context", "Likelihood", "or", "Relatedness", "Network", "algorithm", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/utils/graph.py#L139-L173
[ "def", "clr", "(", "M", ",", "*", "*", "kwargs", ")", ":", "R", "=", "np", ".", "zeros", "(", "M", ".", "shape", ")", "Id", "=", "[", "[", "0", ",", "0", "]", "for", "i", "in", "range", "(", "M", ".", "shape", "[", "0", "]", ")", "]", ...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
aracne
Implementation of the ARACNE algorithm. Args: mat (numpy.ndarray): matrix, if it is a square matrix, the program assumes it is a relevance matrix where mat(i,j) represents the similarity content between nodes i and j. Elements of matrix should be non-negative. Returns: mat_...
cdt/utils/graph.py
def aracne(m, **kwargs): """Implementation of the ARACNE algorithm. Args: mat (numpy.ndarray): matrix, if it is a square matrix, the program assumes it is a relevance matrix where mat(i,j) represents the similarity content between nodes i and j. Elements of matrix should be non-...
def aracne(m, **kwargs): """Implementation of the ARACNE algorithm. Args: mat (numpy.ndarray): matrix, if it is a square matrix, the program assumes it is a relevance matrix where mat(i,j) represents the similarity content between nodes i and j. Elements of matrix should be non-...
[ "Implementation", "of", "the", "ARACNE", "algorithm", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/utils/graph.py#L176-L213
[ "def", "aracne", "(", "m", ",", "*", "*", "kwargs", ")", ":", "I0", "=", "kwargs", ".", "get", "(", "'I0'", ",", "0.0", ")", "# No default thresholding", "W0", "=", "kwargs", ".", "get", "(", "'W0'", ",", "0.05", ")", "# thresholding", "m", "=", "n...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1
valid
remove_indirect_links
Apply deconvolution to a networkx graph. Args: g (networkx.Graph): Graph to apply deconvolution to alg (str): Algorithm to use ('aracne', 'clr', 'nd') kwargs (dict): extra options for algorithms Returns: networkx.Graph: graph with undirected links removed.
cdt/utils/graph.py
def remove_indirect_links(g, alg="aracne", **kwargs): """Apply deconvolution to a networkx graph. Args: g (networkx.Graph): Graph to apply deconvolution to alg (str): Algorithm to use ('aracne', 'clr', 'nd') kwargs (dict): extra options for algorithms Returns: networkx.Graph: g...
def remove_indirect_links(g, alg="aracne", **kwargs): """Apply deconvolution to a networkx graph. Args: g (networkx.Graph): Graph to apply deconvolution to alg (str): Algorithm to use ('aracne', 'clr', 'nd') kwargs (dict): extra options for algorithms Returns: networkx.Graph: g...
[ "Apply", "deconvolution", "to", "a", "networkx", "graph", "." ]
Diviyan-Kalainathan/CausalDiscoveryToolbox
python
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/utils/graph.py#L216-L232
[ "def", "remove_indirect_links", "(", "g", ",", "alg", "=", "\"aracne\"", ",", "*", "*", "kwargs", ")", ":", "alg", "=", "{", "\"aracne\"", ":", "aracne", ",", "\"nd\"", ":", "network_deconvolution", ",", "\"clr\"", ":", "clr", "}", "[", "alg", "]", "ma...
be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1