ontolearn.learners.celoe

Attributes

logger

Classes

CELOE

Class Expression Learning for Ontology Engineering.

Module Contents

ontolearn.learners.celoe.logger
class ontolearn.learners.celoe.CELOE(knowledge_base: AbstractKnowledgeBase = None, reasoner: owlapy.abstracts.AbstractOWLReasoner | None = None, refinement_operator: BaseRefinement[OENode] | None = None, quality_func: AbstractScorer | None = None, heuristic_func: AbstractHeuristic | None = None, terminate_on_goal: bool | None = None, iter_bound: int | None = None, max_num_of_concepts_tested: int | None = None, max_runtime: int | None = None, max_results: int = 10, best_only: bool = False, calculate_min_max: bool = True)[source]

Bases: ontolearn.learners.base.RefinementBasedConceptLearner

Class Expression Learning for Ontology Engineering. .. attribute:: best_descriptions

Best hypotheses ordered.

type:

EvaluatedDescriptionSet[OENode, QualityOrderedNode]

best_only

If False pick only nodes with quality < 1.0, else pick without quality restrictions.

Type:

bool

calculate_min_max

Calculate minimum and maximum horizontal expansion? Statistical purpose only.

Type:

bool

heuristic_func

Function to guide the search heuristic.

Type:

AbstractHeuristic

heuristic_queue

A sorted set that compares the nodes based on Heuristic.

Type:

SortedSet[OENode]

iter_bound

Limit to stop the algorithm after n refinement steps are done.

Type:

int

kb

The knowledge base that the concept learner is using.

Type:

AbstractKnowledgeBase

max_child_length

Limit the length of concepts generated by the refinement operator.

Type:

int

max_he

Maximal value of horizontal expansion.

Type:

int

max_num_of_concepts_tested
Type:

int

max_runtime

Limit to stop the algorithm after n seconds.

Type:

int

min_he

Minimal value of horizontal expansion.

Type:

int

name

Name of the model = ‘celoe_python’.

Type:

str

_number_of_tested_concepts

Yes, you got it. This stores the number of tested concepts.

Type:

int

operator

Operator used to generate refinements.

Type:

BaseRefinement

quality_func
Type:

AbstractScorer

reasoner

The reasoner that this model is using.

Type:

AbstractOWLReasoner

search_tree

Dict to store the TreeNode for a class expression.

Type:

Dict[OWLClassExpression, TreeNode[OENode]]

start_class

The starting class expression for the refinement operation.

Type:

OWLClassExpression

start_time

The time when fit() starts the execution. Used to calculate the total time fit() takes to execute.

Type:

float

terminate_on_goal

Whether to stop the algorithm if a perfect solution is found.

Type:

bool

__slots__ = ('best_descriptions', 'max_he', 'min_he', 'best_only', 'calculate_min_max', 'heuristic_queue',...
name = 'celoe_python'
search_tree: Dict[owlapy.class_expression.OWLClassExpression, TreeNode[OENode]]
heuristic_queue
best_descriptions
best_only = False
calculate_min_max = True
max_he = 0
min_he = 1
next_node_to_expand(step: int) → OENode[source]

Return from the search tree the most promising search tree node to use for the next refinement step.

Returns:

Next search tree node to refine.

Return type:

_N

best_hypotheses(n: int = 1, return_node: bool = False) → owlapy.class_expression.OWLClassExpression | Iterable[owlapy.class_expression.OWLClassExpression] | OENode | Iterable[OENode][source]

Get the current best found hypotheses according to the quality.

Parameters:

n – Maximum number of results.

Returns:

Iterable with hypotheses in form of search tree nodes.

make_node(c: owlapy.class_expression.OWLClassExpression, parent_node: OENode | None = None, is_root: bool = False) → OENode[source]
updating_node(node: OENode)[source]

Removes the node from the heuristic sorted set and inserts it again.

heuristic_queue is a SortedSet keyed by HeuristicOrderedNode, i.e. it orders entries by node.heuristic (then by concept). Refining node changes node.h_exp and, via heuristic_func.apply(…), node.heuristic itself - so node has to be pulled out of the sorted structure before it is mutated and re-inserted after, otherwise the set’s internal ordering invariant (built from the heuristic value at insertion time) would no longer match the node’s current heuristic value.

discard() looks the node up by its current key. If the node’s heuristic already changed since it was added to the queue (e.g. it was mutated somewhere other than through this context manager, or it is being updated a second time without ever having been re-added), the lookup can miss and SortedKeyList.remove() raises ValueError. That would indicate the node’s queue membership and its heuristic attribute have gone out of sync with each other - worth investigating if it is ever observed - but there is nothing to undo here: the node is simply not present in the queue, so we fall through to yield/re-add() as normal.

Parameters:

update. (Node to)

Yields:

The node itself.

downward_refinement(node: OENode) → Iterable[OENode][source]

Execute one refinement step of a refinement based learning algorithm.

Parameters:

node (_N) – the search tree node on which to refine.

Returns:

Refinement results as new search tree nodes (they still need to be added to the tree).

Return type:

Iterable[_N]

fit(*args, **kwargs)[source]

Find hypotheses that explain pos and neg.

encoded_learning_problem() → EncodedPosNegLPStandardKind | None[source]

Fetch the most recently used learning problem from the fit method.

tree_node(node: OENode) → TreeNode[OENode][source]

Get the TreeNode of the given node.

Parameters:

node – The node.

Returns:

TreeNode of the given node.

show_search_tree(heading_step: str, top_n: int = 10) → None[source]

Show search tree.

update_min_max_horiz_exp(node: OENode)[source]
clean()[source]

Clear all states of the concept learner.