ontolearn.learners.tree_learner =============================== .. py:module:: ontolearn.learners.tree_learner Classes ------- .. autoapisummary:: ontolearn.learners.tree_learner.TDL Functions --------- .. autoapisummary:: ontolearn.learners.tree_learner.explain_inference ontolearn.learners.tree_learner.concepts_reducer Module Contents --------------- .. py:function:: explain_inference(clf, X: pandas.DataFrame) Given a trained Decision Tree, extract the paths from root to leaf nodes for each entities https://scikit-learn.org/stable/auto_examples/tree/plot_unveil_tree_structure.html#understanding-the-decision-tree-structure .. py:function:: concepts_reducer(concepts: List[owlapy.class_expression.OWLClassExpression], reduced_cls: Callable) -> Union[owlapy.class_expression.OWLObjectUnionOf, owlapy.class_expression.OWLObjectIntersectionOf] Reduces a list of OWLClassExpression instances into a single instance of OWLObjectUnionOf or OWLObjectIntersectionOf .. py:class:: TDL(knowledge_base, use_inverse: bool = False, use_data_properties: bool = False, use_nominals: bool = False, use_card_restrictions: bool = False, kwargs_classifier: dict = None, max_runtime: int = 1, grid_search_over: dict = None, grid_search_apply: bool = False, report_classification: bool = True, plot_tree: bool = False, plot_embeddings: bool = False, plot_feature_importance: bool = False, verbose: int = 10, verbalize: bool = False) Tree-based Description Logic Concept Learner .. py:attribute:: use_nominals :value: False .. py:attribute:: use_card_restrictions :value: False .. py:attribute:: grid_search_over :value: None .. py:attribute:: knowledge_base .. py:attribute:: report_classification :value: True .. py:attribute:: plot_tree :value: False .. py:attribute:: plot_embeddings :value: False .. py:attribute:: plot_feature_importance :value: False .. py:attribute:: clf :value: None .. py:attribute:: kwargs_classifier .. py:attribute:: max_runtime :value: 1 .. py:attribute:: features :value: None .. py:attribute:: disjunction_of_conjunctive_concepts :value: None .. py:attribute:: conjunctive_concepts :value: None .. py:attribute:: owl_class_expressions .. py:attribute:: cbd_mapping :type: Dict[str, Set[Tuple[str, str]]] .. py:attribute:: types_of_individuals .. py:attribute:: verbose :value: 10 .. py:attribute:: verbalize :value: False .. py:attribute:: data_property_cast .. py:attribute:: X :value: None .. py:attribute:: y :value: None .. py:method:: extract_expressions_from_owl_individuals(individuals: List[owlapy.owl_individual.OWLNamedIndividual]) -> Tuple[Dict[str, owlapy.class_expression.OWLClassExpression], Dict[str, str]] .. py:method:: construct_sparse_binary_representations(features: List[owlapy.class_expression.OWLClassExpression], examples: List[owlapy.owl_individual.OWLNamedIndividual], examples_to_features) -> numpy.array .. py:method:: create_training_data(learning_problem: ontolearn.learning_problem.PosNegLPStandard) -> Tuple[pandas.DataFrame, pandas.DataFrame] .. py:method:: construct_owl_expression_from_tree(X: pandas.DataFrame, y: pandas.DataFrame) -> List[owlapy.class_expression.OWLObjectIntersectionOf] Construct an OWL class expression from a decision tree .. py:method:: fit(learning_problem: ontolearn.learning_problem.PosNegLPStandard = None, max_runtime: int = None) Fit the learner to the given learning problem (1) Extract multi-hop information about E^+ and E^-. (2) Create OWL Class Expressions from (1) (3) Build a binary sparse training data X where first |E+| rows denote the binary representations of positives Remaining rows denote the binary representations of E⁻ (4) Create binary labels. (4) Construct a set of DL concept for each e \in E^+ (5) Union (4) :param learning_problem: The learning problem :param max_runtime:total runtime of the learning .. py:property:: classification_report :type: str .. py:method:: best_hypotheses(n=1) -> Tuple[owlapy.class_expression.OWLClassExpression, List[owlapy.class_expression.OWLClassExpression]] Return the prediction .. py:method:: predict(X: List[owlapy.owl_individual.OWLNamedIndividual], proba=True) -> numpy.ndarray :abstractmethod: Predict the likelihoods of individuals belonging to the classes