ontolearn.learners.clip

CLIP: Concept Learner with Integrated Length Prediction.

Classes

CLIP

Concept Learner with Integrated Length Prediction.

Module Contents

class ontolearn.learners.clip.CLIP(knowledge_base: AbstractKnowledgeBase, reasoner: owlapy.abstracts.AbstractOWLReasoner | None = None, refinement_operator: BaseRefinement[OENode] | None = ExpressRefinement, 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, path_of_embeddings='', predictor_name=None, pretrained_predictor_name=['SetTransformer', 'LSTM', 'GRU', 'CNN'], load_pretrained=False, num_workers=4, num_examples=1000, output_size=15)[source]

Bases: ontolearn.learners.CELOE

Concept Learner with Integrated Length Prediction. This algorithm extends the CELOE algorithm by using concept length predictors and a different refinement operator, i.e., ExpressRefinement

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 = 'CLIP'
predictor_name = None
pretrained_predictor_name = ['SetTransformer', 'LSTM', 'GRU', 'CNN']
knowledge_base
load_pretrained = False
num_workers = 4
output_size = 15
num_examples = 1000
path_of_embeddings = ''
device
length_predictor
get_length_predictor()[source]
refresh()[source]
collate_batch(batch)[source]
collate_batch_inference(batch)[source]
pos_neg_to_tensor(pos: List[owlapy.owl_individual.OWLNamedIndividual] | List[str], neg: List[owlapy.owl_individual.OWLNamedIndividual] | List[str])[source]
predict_length(models, x_pos, x_neg)[source]
fit(*args, **kwargs)[source]

Find hypotheses that explain pos and neg.

train(data: Iterable[List[Tuple]], epochs=300, batch_size=256, learning_rate=0.001, decay_rate=0.0, clip_value=5.0, save_model=True, storage_path=None, optimizer='Adam', record_runtime=True, example_sizes=None, shuffle_examples=False)[source]

Optional training hook; a no-op by default.

Training is learner-specific: learners that require training (e.g. Drill, NCES, NCES2, ROCES, CLIP) override this method with their own signatures, while purely symbolic learners (e.g. CELOE, OCEL) need no training. This default exists so that untrainable learners can be used in generic pipelines that call train() uniformly (e.g. ontolearn.experiments.Experiments.carry_out_kfold_cross_validation()).

Returns:

self.