@@ -576,13 +576,9 @@ def get_variable_statistics(self, variable_name):
576576 -------
577577 `VariableStatistics`
578578 The statistics of the specified variable.
579-
580- Raises
581- ------
582- `KeyError`
583- If no variable with the specified names exist.
579+ A ``None`` value is returned if the variable name is not found.
584580 """
585- return self ._variables_statistics_by_name [ variable_name ]
581+ return self ._variables_statistics_by_name . get ( variable_name )
586582
587583 def get_tree (self , tree_name ):
588584 """Returns the tree with the specified name
@@ -596,13 +592,9 @@ def get_tree(self, tree_name):
596592 -------
597593 `Tree`
598594 The tree which has the specified name.
599-
600- Raises
601- ------
602- `KeyError`
603- If no tree with the specified name exists.
595+ A ``None`` value is returned if the tree name is not found.
604596 """
605- return self ._trees_by_name [ tree_name ]
597+ return self ._trees_by_name . get ( tree_name )
606598
607599 def to_dict (self ):
608600 """Transforms this instance to a dict with the Khiops JSON file structure"""
@@ -1045,15 +1037,12 @@ def get_variable_pair_statistics(self, variable_name_1, variable_name_2):
10451037 -------
10461038 `VariablePairStatistics`
10471039 The statistics of the specified pair of variables.
1048-
1049- Raises
1050- ------
1051- `KeyError`
1052- If no pair with the specified names exist.
1040+ A ``None`` value is returned if no pair with the
1041+ specified names exist.
10531042 """
1054- return self ._variables_pairs_statistics_by_name [
1043+ return self ._variables_pairs_statistics_by_name . get (
10551044 (variable_name_1 , variable_name_2 )
1056- ]
1045+ )
10571046
10581047 def to_dict (self ):
10591048 """Transforms this instance to a dict with the Khiops JSON file structure"""
@@ -1307,13 +1296,9 @@ def get_predictor(self, predictor_name):
13071296 -------
13081297 `TrainedPredictor`
13091298 The predictor object for the specified name.
1310-
1311- Raises
1312- ------
1313- `KeyError`
1314- If there is no predictor with the specified name.
1299+ A ``None`` value is returned if the predictor name is not found.
13151300 """
1316- return self ._trained_predictors_by_name [ predictor_name ]
1301+ return self ._trained_predictors_by_name . get ( predictor_name )
13171302
13181303 def get_snb_predictor (self ):
13191304 """Returns the Selective Naive Bayes predictor
@@ -1322,11 +1307,8 @@ def get_snb_predictor(self):
13221307 -------
13231308 `TrainedPredictor`
13241309 The predictor object for "Selective Naive Bayes".
1325-
1326- Raises
1327- ------
1328- `KeyError`
1329- If there is no predictor named "Selective Naive Bayes".
1310+ A ``None`` value is returned
1311+ if there is no predictor named "Selective Naive Bayes".
13301312 """
13311313 return self .get_predictor ("Selective Naive Bayes" )
13321314
@@ -1589,13 +1571,9 @@ def get_predictor_performance(self, predictor_name):
15891571 -------
15901572 `PredictorPerformance`
15911573 The performance metrics for the specified predictor.
1592-
1593- Raises
1594- ------
1595- `KeyError`
1596- If no predictor with the specified name exists.
1574+ A ``None`` value is returned if the predictor name is not found.
15971575 """
1598- return self ._predictors_performance_by_name [ predictor_name ]
1576+ return self ._predictors_performance_by_name . get ( predictor_name )
15991577
16001578 def get_snb_performance (self ):
16011579 """Returns the performance metrics for the Selective Naive Bayes predictor
@@ -1625,21 +1603,20 @@ def get_regressor_rec_curve(self, regressor_name):
16251603 Returns
16261604 -------
16271605 `PredictorCurve`
1628- The REC curve for the specified regressor.
1606+ The REC curve for the specified regressor. A ``None`` value is
1607+ returned if the regressor name is not found.
16291608
16301609 Raises
16311610 ------
16321611 `ValueError`
1633- If no regressor curves available. (
1634- `KeyError`
1635- If no regressor with the specified name exists.
1612+ If no regressor curves available.
16361613 """
16371614 if self .learning_task != "Regression analysis" :
16381615 raise ValueError ("REC curves are available only for regression" )
16391616 for curve in self .regression_rec_curves :
16401617 if curve .name == regressor_name :
16411618 return curve
1642- raise KeyError ( regressor_name )
1619+ return None
16431620
16441621 def get_snb_rec_curve (self ):
16451622 """Returns the REC curve for the Selective Naive Bayes regressor
@@ -1675,11 +1652,8 @@ def get_classifier_lift_curve(self, classifier_name, target_value):
16751652 -------
16761653 `PredictorCurve`
16771654 The lift curve for the specified classifier and target value.
1678-
1679- Raises
1680- ------
1681- `KeyError`
1682- If no classifier with the specified exists or no target value with the
1655+ A ``None`` value is returned
1656+ if no classifier with the specified exists or no target value with the
16831657 specified name exists.
16841658 """
16851659 if self .learning_task != "Classification analysis" :
@@ -1701,8 +1675,7 @@ def get_classifier_lift_curve(self, classifier_name, target_value):
17011675 for lift_curve in self .classification_lift_curves [i ]:
17021676 if lift_curve .name == classifier_name :
17031677 return lift_curve
1704- raise KeyError (classifier_name )
1705- raise KeyError (target_value )
1678+ return None
17061679
17071680 def get_snb_lift_curve (self , target_value ):
17081681 """Returns lift curve for the Selective Naive Bayes clf. given a target value
@@ -1716,14 +1689,8 @@ def get_snb_lift_curve(self, target_value):
17161689 -------
17171690 `PredictorCurve`
17181691 The lift curve of the Selective Naive Bayes classifier for the specified
1719- target value.
1720-
1721- Raises
1722- ------
1723- `ValueError`
1724- If the Selective Naive Bayes classifier information is not available.
1725- `KeyError`
1726- If no target value with the specified name exists.
1692+ target value. A ``None`` value is returned if no Selective Naive Bayes
1693+ classifier information is available.
17271694 """
17281695 if self .learning_task != "Classification analysis" :
17291696 raise ValueError ("Lift curves are available only for classification" )
@@ -1732,10 +1699,7 @@ def get_snb_lift_curve(self, target_value):
17321699 for lift_curve in self .classification_lift_curves [i ]:
17331700 if lift_curve .name == "Selective Naive Bayes" :
17341701 return lift_curve
1735- raise ValueError (
1736- "Selective Naive Bayes classifier information not available"
1737- )
1738- raise KeyError (target_value )
1702+ return None
17391703
17401704 def to_dict (self ):
17411705 """Transforms this instance to a dict with the Khiops JSON file structure"""
0 commit comments