graphid.core.mixin_priority module

class graphid.core.mixin_priority.Priority[source]

Bases: object

Handles prioritization of edges for review.

Example

>>> from graphid.core.mixin_priority import *  # NOQA
>>> from graphid import demo
>>> infr = demo.demodata_infr(num_pccs=20)
remaining_reviews()[source]
_pop(*args)[source]

Wraps queue so ordering is determenistic

_push(edge, priority)[source]

Wraps queue so ordering is determenistic

_peek_many(n)[source]

Wraps queue so ordering is determenistic

_remove_edge_priority(edges)[source]
_reinstate_edge_priority(edges)[source]
_increase_priority(edges, amount=10)[source]
remove_internal_priority(cc)[source]
reinstate_internal_priority(cc)[source]
prioritize(metric=None, edges=None, scores=None, force_inconsistent=True, reset=False)[source]

Adds edges to the priority queue.

Note that these edges must already exist in the infr.unreviewed_graph as unreviewed edges. By default the prob_match edge attribute is used to sort edges. If you have registered a verification algorithm, then these scores are computed using infr.ensure_priority_scores(edges). However, you can have all this done for you by simply calling infr.add_candidate_edges(edges) or infr.refresh_candidate_edges().

Example

>>> from graphid.core.mixin_priority import *  # NOQA
>>> from graphid import demo
>>> infr = demo.demodata_infr(num_pccs=7, size=5)
>>> infr.ensure_cliques(meta_decision=SAME)
>>> # Add a negative edge inside a PCC
>>> ccs = list(infr.positive_components())
>>> edge1 = tuple(list(ccs[0])[0:2])
>>> edge2 = tuple(list(ccs[1])[0:2])
>>> infr.add_feedback(edge1, NEGTV)
>>> infr.add_feedback(edge2, NEGTV)
>>> num_new = infr.prioritize(reset=True)
>>> order = infr._peek_many(np.inf)
>>> scores = util.take_column(order, 1)
>>> assert scores[0] > 10
>>> assert len(scores) == num_new, 'should prioritize two hypotheis edges'
>>> unrev_edges = set(infr.unreviewed_graph.edges())
>>> err_edges = set(ub.flatten(infr.nid_to_errors.values()))
>>> edges = set(list(unrev_edges - err_edges)[0:2])
>>> edges.update(list(err_edges)[0:2])
>>> num_new = infr.prioritize(edges=edges, reset=True)
>>> order2 = infr._peek_many(np.inf)
>>> scores2 = np.array(util.take_column(order2, 1))
>>> assert np.all(scores2[0:2] > 10)
>>> assert np.all(scores2[2:] < 10)
push(edge, priority=None)[source]

Push an edge back onto the queue

pop()[source]

Main interface to the priority queue used by the algorithm loops. Pops the highest priority edge from the queue.

peek()[source]
peek_many(n)[source]

Peeks at the top n edges in the queue.

Example

>>> # ENABLE_DOCTEST
>>> from graphid.core.mixin_priority import *  # NOQA
>>> from graphid import demo
>>> infr = demo.demodata_infr(num_pccs=7, size=5)
>>> infr.refresh_candidate_edges()
>>> infr.peek_many(50)
confidently_connected(u, v, thresh=2)[source]

Checks if u and v are conneted by edges above a confidence threshold

confidently_separated(u, v, thresh=2)[source]

Checks if u and v are conneted by edges above a confidence threshold

Example

>>> from graphid.core.mixin_priority import *  # NOQA
>>> from graphid import demo
>>> infr = demo.demodata_infr(ccs=[(1, 2), (3, 4), (5, 6), (7, 8)])
>>> infr.add_feedback((1, 5), NEGTV)
>>> infr.add_feedback((5, 8), NEGTV)
>>> infr.add_feedback((6, 3), NEGTV)
>>> u, v = (1, 4)
>>> thresh = 0
>>> assert not infr.confidently_separated(u, v, thresh)
>>> infr.add_feedback((2, 3), NEGTV)
>>> assert not infr.confidently_separated(u, v, thresh)
generate_reviews(pos_redun=None, neg_redun=None, data=False)[source]

Dynamic generator that yeilds high priority reviews

_generate_reviews(data=False)[source]