ontolearn.learners.evolearner
EvoLearner: An evolutionary approach to learn concepts in ALCQ(D).
Classes
An evolutionary approach to learn concepts in ALCQ(D). |
Module Contents
- class ontolearn.learners.evolearner.EvoLearner(knowledge_base: AbstractKnowledgeBase, reasoner: owlapy.abstracts.AbstractOWLReasoner | None = None, quality_func: AbstractScorer | None = None, fitness_func: AbstractFitness | None = None, init_method: AbstractEAInitialization | None = None, algorithm: AbstractEvolutionaryAlgorithm | None = None, mut_uniform_gen: AbstractEAInitialization | None = None, value_splitter: AbstractValueSplitter | None = None, terminate_on_goal: bool | None = None, max_runtime: int | None = None, use_data_properties: bool = True, use_card_restrictions: bool = True, use_inverse: bool = False, tournament_size: int = 7, card_limit: int = 10, population_size: int = 800, num_generations: int = 200, height_limit: int = 17)[source]
Bases:
ontolearn.learners.base.BaseConceptLearnerAn evolutionary approach to learn concepts in ALCQ(D).
- algorithm
The evolutionary algorithm.
- card_limit
The upper cardinality limit if using cardinality restriction on object properties.
- Type:
int
- fitness_func
Fitness function.
- Type:
- height_limit
The maximum value allowed for the height of the Crossover and Mutation operations.
- Type:
int
- init_method
The evolutionary algorithm initialization method.
- Type:
- kb
The knowledge base that the concept learner is using.
- Type:
- max_num_of_concepts_tested
Limit to stop the algorithm after n concepts tested.
- Type:
int
- max_runtime
max_runtime: Limit to stop the algorithm after n seconds.
- Type:
int
- mut_uniform_gen
The initialization method to create the tree for mutation operation.
- Type:
- name
Name of the model = ‘evolearner’.
- Type:
str
- num_generations
Number of generation for the evolutionary algorithm.
- Type:
int
- _number_of_tested_concepts
Yes, you got it. This stores the number of tested concepts.
- Type:
int
- population_size
Population size for the evolutionary algorithm.
- Type:
int
- pset
Contains the primitives that can be used to solve a Strongly Typed GP problem.
- Type:
gp.PrimitiveSetTyped
- quality_func
Function to evaluate the quality of solution concepts.
- reasoner
The reasoner that this model is using.
- Type:
AbstractOWLReasoner
- start_time
The time when
fit()starts the execution. Used to calculate the total timefit()takes to execute.- Type:
float
- terminate_on_goal
Whether to stop the algorithm if a perfect solution is found.
- Type:
bool
- toolbox
A toolbox for evolution that contains the evolutionary operators.
- Type:
base.Toolbox
- tournament_size
The number of evolutionary individuals participating in each tournament.
- Type:
int
- use_card_restrictions
Use cardinality restriction for object properties?
- Type:
bool
- use_data_properties
Consider data properties?
- Type:
bool
- use_inverse
Consider inversed concepts?
- Type:
bool
- value_splitter
Used to calculate the splits for data properties values.
- Type:
- __slots__ = ('fitness_func', 'init_method', 'algorithm', 'value_splitter', 'tournament_size',...
- name = 'evolearner'
- fitness_func: AbstractFitness
- init_method: AbstractEAInitialization
- algorithm: AbstractEvolutionaryAlgorithm
- mut_uniform_gen: AbstractEAInitialization
- value_splitter: AbstractValueSplitter
- use_data_properties: bool
- use_card_restrictions: bool
- use_inverse: bool
- tournament_size: int
- card_limit: int
- population_size: int
- num_generations: int
- height_limit: int
- generator: ConceptGenerator
- pset: deap.gp.PrimitiveSetTyped
- toolbox: deap.base.Toolbox
- reasoner = None
- total_fits = 0
- register_op(alias: str, function: Callable, *args, **kargs)[source]
Register a function in the toolbox under the name alias. You may provide default arguments that will be passed automatically when calling the registered function. Fixed arguments can then be overriden at function call time.
- Parameters:
alias – The name the operator will take in the toolbox. If the alias already exist it will overwrite the operator already present.
function – The function to which refer the alias.
args – One or more argument (and keyword argument) to pass automatically to the registered function when called, optional.
- fit(*args, **kwargs) EvoLearner[source]
Find hypotheses that explain pos and neg.
- best_hypotheses(n: int = 1, key: str = 'fitness', return_node: bool = False) owlapy.class_expression.OWLClassExpression | Iterable[owlapy.class_expression.OWLClassExpression][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.