:py:mod:`ontolearn.model_adapter` ================================= .. py:module:: ontolearn.model_adapter .. autoapi-nested-parse:: Model adapters. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: ontolearn.model_adapter.Trainer Functions ~~~~~~~~~ .. autoapisummary:: ontolearn.model_adapter.transform_string ontolearn.model_adapter.compute_quality ontolearn.model_adapter.ModelAdapter ontolearn.model_adapter.execute Attributes ~~~~~~~~~~ .. autoapisummary:: ontolearn.model_adapter.logger ontolearn.model_adapter.metrics ontolearn.model_adapter.models ontolearn.model_adapter.heuristics .. py:data:: logger .. py:data:: metrics .. py:data:: models .. py:data:: heuristics .. py:function:: transform_string(input_string) Used to turn camelCase arguments to snake_case .. py:function:: compute_quality(KB, solution, pos, neg, qulaity_func='f1') .. py:function:: ModelAdapter(*args, **kwargs) Instantiate a model through the model adapter. .. warning :: You should not specify both: the _type and the object. For example, you should not give both 'reasoner' and 'reasoner_type' because the ModelAdapter cant decide which one to use, the reasoner object or create a new reasoner instance using 'reasoner_type'. .. note:: If you give `_type` for an argument you can pass further arguments to construct the instance of that class. The model adapter will arrange every argument automatically and use them to construct an object for that certain class type. :param knowledge_base: A knowledge base. :type knowledge_base: AbstractKnowledgeBase :param knowledge_base_type: A knowledge base type. :param ...: Knowledge base arguments. :param reasoner: A reasoner. :param reasoner_type: A reasoner type. :param ...: Reasoner constructor arguments. :param refinement_operator_type: A refinement operator type. :param ...: Refinement operator arguments. :param quality_type: An Abstract Scorer type. :param ...: Quality arguments. :param heuristic_func: A heuristic. :type heuristic_func: AbstractHeuristic :param heuristic_type: An Abstract Heuristic type. :param ...: arguments For the heuristic type. :param learner_type: A Base Concept Learner type. :param ...: Arguments for the learning algorithm. .. py:class:: Trainer(learner: ontolearn.base_concept_learner.BaseConceptLearner, reasoner: owlapy.owl_reasoner.OWLReasoner) .. py:method:: fit(*args, **kwargs) Run the concept learning algorithm according to its configuration. Once finished, the results can be queried with the `best_hypotheses` function. .. py:method:: best_hypotheses(n) Get the current best found hypotheses according to the quality. :param n: Maximum number of results. :returns: Iterable with hypotheses in form of search tree nodes. .. py:method:: predict(individuals: List[owlapy.owl_individual.OWLNamedIndividual], hypotheses: Optional[List[Union[_N, owlapy.class_expression.OWLClassExpression]]] = None, axioms: Optional[List[owlapy.owl_axiom.OWLAxiom]] = None, n: int = 10) Creates a binary data frame showing for each individual whether it is entailed in the given hypotheses (class expressions). The individuals do not have to be in the ontology/knowledge base yet. In that case, axioms describing these individuals must be provided. The state of the knowledge base/ontology is not changed, any provided axioms will be removed again. :param individuals: A list of individuals/instances. :param hypotheses: (Optional) A list of search tree nodes or class expressions. If not provided, the current :func:`BaseConceptLearner.best_hypothesis` of the concept learner are used. :param axioms: (Optional) A list of axioms that are not in the current knowledge base/ontology. If the individual list contains individuals that are not in the ontology yet, axioms describing these individuals must be provided. The argument can also be used to add arbitrary axioms to the ontology for the prediction. :param n: Integer denoting number of ALC concepts to extract from search tree if hypotheses=None. :returns: Pandas data frame with dimensions |individuals|*|hypotheses| indicating for each individual and each hypothesis whether the individual is entailed in the hypothesis. .. py:method:: save_best_hypothesis(n: int = 10, path: str = 'Predictions', rdf_format: str = 'rdfxml') -> None Serialise the best hypotheses to a file. :param n: Maximum number of hypotheses to save. :param path: Filename base (extension will be added automatically). :param rdf_format: Serialisation format. currently supported: "rdfxml". .. py:function:: execute(args)