graphid.demo package

Submodules

Module contents

Regenerate Input Command mkinit graphid.demo –lazy_loader_typed

class graphid.demo.DummyRanker(verif)[source]

Bases: object

Generates dummy rankings

predict_candidate_edges(nodes, K=10)[source]

CommandLine

python -m graphid.demo.dummy_algos DummyRanker.predict_candidate_edges

Example

>>> from graphid import demo
>>> kwargs = dict(num_pccs=40, size=2)
>>> infr = demo.demodata_infr(**kwargs)
>>> edges = list(infr.ranker.predict_candidate_edges(infr.aids, K=100))
>>> scores = np.array(infr.verifier.predict_edges(edges))
>>> assert len(edges) > 0
predict_rankings(nodes, K=10)[source]

Yields a list ranked edges connected to each node.

predict_single_ranking(u, K=10)[source]

simulates the ranking algorithm. Order is defined using the dummy vsone scores, but tests are only applied to randomly selected gt and gf pairs. So, you usually will get a gt result, but you might not if all the scores are bad.

class graphid.demo.DummyVerif(infr)[source]

Bases: object

Generates dummy scores between pairs of annotations. (not necesarilly existing edges in the graph)

CommandLine

python -m graphid.demo DummyVerif:1

Example

>>> from graphid.demo import *  # NOQA
>>> from graphid import demo
>>> kwargs = dict(num_pccs=6, p_incon=.5, size_std=2)
>>> infr = demo.demodata_infr(**kwargs)
>>> infr.dummy_verif.predict_edges([(1, 2)])
>>> infr.dummy_verif.predict_edges([(1, 21)])
>>> assert len(infr.dummy_verif.infr.task_probs['match_state']) == 2
_get_truth(edge)[source]
predict_edges(edges)[source]
predict_proba_df(edges)[source]

CommandLine

python -m graphid.demo DummyVerif.predict_edges

Example

>>> from graphid import demo
>>> kwargs = dict(num_pccs=40, size=2)
>>> infr = demo.demodata_infr(**kwargs)
>>> verif = infr.dummy_verif
>>> edges = list(infr.graph.edges())
>>> probs = verif.predict_proba_df(edges)
show_score_probs()[source]

CommandLine

python -m graphid.demo.dummy_algos DummyVerif.show_score_probs --show

Example

>>> from graphid import core
>>> from graphid import demo
>>> infr = core.AnnotInference()
>>> verif = demo.DummyVerif(infr)
>>> verif.show_score_probs()
>>> util.show_if_requested()
graphid.demo.demodata_infr(**kwargs)[source]
Kwargs:

num_pccs (list): implicit number of individuals ccs (list): explicit list of connected components

p_incon (float): probability a PCC is inconsistent p_incomp (float): probability an edge is incomparable n_incon (int): target number of inconsistent components (default 3)

pcc_size_mean (int): average number of annots per PCC pcc_size_std (float): std dev of annots per PCC

pos_redun (int): desired level of positive redundancy

infer (bool): whether or not to run inference by default default True

ignore_pair (bool): if True ignores all pairwise dummy edge generation p_pair_neg (float): default = .4 p_pair_incmp (float): default = .2 p_pair_unrev (float): default = 0.0

CommandLine

python -m graphid.demo.dummy_infr demodata_infr:0 --show
python -m graphid.demo.dummy_infr demodata_infr:1 --show
python -m utool.util_inspect recursive_parse_kwargs:2 --mod graphid.demo.dummy_infr --func demodata_infr

Example

>>> from graphid import demo
>>> import networkx as nx
>>> kwargs = dict(num_pccs=6, p_incon=.5, size_std=2)
>>> infr = demo.demodata_infr(**kwargs)
>>> pccs = list(infr.positive_components())
>>> assert len(pccs) == kwargs['num_pccs']
>>> nonfull_pccs = [cc for cc in pccs if len(cc) > 1 and nx.is_empty(nx.complement(infr.pos_graph.subgraph(cc)))]
>>> expected_n_incon = len(nonfull_pccs) * kwargs['p_incon']
>>> n_incon = len(list(infr.inconsistent_components()))
>>> print('status = ' + ub.urepr(infr.status(extended=True)))
>>> # xdoctest: +REQUIRES(--show)
>>> infr.show(pickable=True, groupby='name_label')
>>> util.show_if_requested()

Doctest

>>> from graphid import demo
>>> import networkx as nx
>>> kwargs = dict(num_pccs=0)
>>> infr = demo.demodata_infr(**kwargs)
graphid.demo.run_demo()[source]

CommandLine

python -m graphid.demo.demo_script run_demo --viz
python -m graphid.demo.demo_script run_demo

Example

>>> run_demo()