@@ -325,7 +325,7 @@ def __init__(self, knowledge_base,
325325 isinstance (knowledge_base , KnowledgeBase )
326326 or isinstance (knowledge_base , ontolearn .triple_store .TripleStore )
327327 ), "knowledge_base must be a KnowledgeBase or TripleStore instance"
328- print (f"Knowledge Base: { knowledge_base } " )
328+ logger . info (f"Knowledge Base: { knowledge_base } " )
329329 self .grid_search_over = grid_search_over
330330 self .kwargs_grid_search = kwargs_grid_search
331331 self .knowledge_base = knowledge_base
@@ -456,7 +456,7 @@ def extract_expressions_from_owl_individuals(self, individuals: List[OWLNamedInd
456456 )
457457 raise AssertionError (error_msg )
458458 if self .verbose > 0 :
459- print (f"Unique OWL Class Expressions as features: { len (features )} " )
459+ logger . info (f"Unique OWL Class Expressions as features: { len (features )} " )
460460 feature_options = {
461461 "inverse properties" : self .use_inverse ,
462462 "nominals" : self .use_nominals ,
@@ -469,7 +469,7 @@ def extract_expressions_from_owl_individuals(self, individuals: List[OWLNamedInd
469469 enabled = [name for name , flag in feature_options .items () if flag ]
470470
471471 if enabled :
472- print (f"Enabled feature types: { ', ' .join (enabled )} " )
472+ logger . info (f"Enabled feature types: { ', ' .join (enabled )} " )
473473
474474 # Convert features dict to list
475475 features_list = [v for k , v in features .items ()]
@@ -539,8 +539,6 @@ def _extract_inverse_property_features(self, individual: OWLNamedIndividual,
539539 break # Found at least one, that's enough for the feature
540540 except Exception as e :
541541 logger .warning ("Error extracting inverse property features for %s: %s" , individual , e , exc_info = True )
542- if self .verbose > 0 :
543- print (f"Warning: Error extracting inverse property features: { e } " )
544542
545543 def _extract_data_property_features (self , individual : OWLNamedIndividual ,
546544 features : Dict [str , OWLClassExpression ],
@@ -560,8 +558,6 @@ def _extract_data_property_features(self, individual: OWLNamedIndividual,
560558 pass
561559 except Exception as e :
562560 logger .warning ("Error extracting data property features for %s: %s" , individual , e , exc_info = True )
563- if self .verbose > 0 :
564- print (f"Warning: Error extracting data property features: { e } " )
565561
566562 def _extract_cardinality_features (self , individual : OWLNamedIndividual ,
567563 features : Dict [str , OWLClassExpression ],
@@ -606,14 +602,12 @@ def _extract_cardinality_features(self, individual: OWLNamedIndividual,
606602 features [str_dl_concept ] = min_card
607603 except Exception as e :
608604 logger .warning ("Error extracting cardinality features for %s: %s" , individual , e , exc_info = True )
609- if self .verbose > 0 :
610- print (f"Warning: Error extracting cardinality features: { e } " )
611605
612606
613607 def create_training_data (self , learning_problem : PosNegLPStandard , start_time :float = None ) -> Tuple [pd .DataFrame , pd .DataFrame ]:
614608 # (1) Initialize ordering over positive and negative examples.
615609 if self .verbose > 0 :
616- print ("Creating a Training Dataset" )
610+ logger . info ("Creating a Training Dataset" )
617611 positive_examples : List [OWLNamedIndividual ]
618612 negative_examples : List [OWLNamedIndividual ]
619613 positive_examples = [i for i in learning_problem .pos ]
@@ -686,11 +680,11 @@ def _fit_decision_tree(self, X: pd.DataFrame, y: pd.DataFrame) -> None:
686680 grid_search = sklearn .model_selection .GridSearchCV (
687681 tree .DecisionTreeClassifier (** self .kwargs_classifier ),
688682 param_grid = self .grid_search_over , ** self .kwargs_grid_search ).fit (X .values , y .values )
689- print ( grid_search .best_params_ )
683+ logger . info ( f"Best grid search parameters: { grid_search .best_params_ } " )
690684 self .kwargs_classifier .update (grid_search .best_params_ )
691685 # Training
692686 if self .verbose > 0 :
693- print ("Training starts!" )
687+ logger . info ("Training starts!" )
694688 self .clf = tree .DecisionTreeClassifier (** self .kwargs_classifier ).fit (X = X .values , y = y .values )
695689
696690 def _report_and_plot (self , X : pd .DataFrame , y : pd .DataFrame ) -> None :
@@ -703,7 +697,7 @@ def _report_and_plot(self, X: pd.DataFrame, y: pd.DataFrame) -> None:
703697 target_names = ["Negative" ,
704698 "Positive" ])
705699 if self .verbose > 0 :
706- print (self .__classification_report )
700+ logger . info (self .__classification_report )
707701 if self .plot_tree :
708702 plot_decision_tree_of_expressions (feature_names = [owl_expression_to_dl (f ) for f in self .features ],
709703 cart_tree = self .clf )
@@ -720,12 +714,12 @@ def _finalize_predictions(self, X: pd.DataFrame, y: pd.DataFrame) -> None:
720714 # ending in a leaf node.
721715 self .conjunctive_concepts : List [OWLObjectIntersectionOf ]
722716 if self .verbose > 0 :
723- print ("Computing conjunctive_concepts..." )
717+ logger . info ("Computing conjunctive_concepts..." )
724718 self .conjunctive_concepts = self .construct_owl_expression_from_tree (X , y )
725719 for i in self .conjunctive_concepts :
726720 self .owl_class_expressions .add (i )
727721 if self .verbose > 0 :
728- print ("Computing disjunction_of_conjunctive_concepts..." )
722+ logger . info ("Computing disjunction_of_conjunctive_concepts..." )
729723 self .disjunction_of_conjunctive_concepts = concepts_reducer (concepts = self .conjunctive_concepts , reduced_cls = OWLObjectUnionOf )
730724
731725 if self .verbalize :
0 commit comments