11from ..utils import DataikuException
22from ..utils import DataikuUTF8CSVReader
33from ..utils import DataikuStreamedHttpUTF8CSVReader
4- from ..utils import DSSExtensibleDict
4+ from ..utils import DSSInternalDict
55import json
66import time
77from .metrics import ComputedMetrics
@@ -723,7 +723,7 @@ def get_partial_dependencies(self):
723723 return DSSPartialDependencies (data )
724724
725725
726- class DSSSubpopulationGlobal (DSSExtensibleDict ):
726+ class DSSSubpopulationGlobal (DSSInternalDict ):
727727 """
728728 Object to read details of performance on global population used for subpopulation analyses.
729729
@@ -761,7 +761,7 @@ def get_prediction_info(self):
761761 }
762762
763763
764- class DSSSubpopulationModality (DSSExtensibleDict ):
764+ class DSSSubpopulationModality (DSSInternalDict ):
765765 """
766766 Object to read details of a subpopulation analysis modality
767767
@@ -777,12 +777,6 @@ def __init__(self, feature_name, computed_as_type, data, prediction_type):
777777 elif computed_as_type == "NUMERIC" :
778778 self .definition = DSSSubpopulationNumericModalityDefinition (feature_name , data )
779779
780- def get_raw (self ):
781- """
782- Gets the raw dictionary of the subpopulation analysis modality
783- """
784- return self .internal_dict
785-
786780 def get_definition (self ):
787781 """
788782 Gets the definition of the subpopulation analysis modality
@@ -890,7 +884,7 @@ def __repr__(self):
890884 return "DSSSubpopulationCategoryModalityDefinition(%s='%s')" % (self .feature_name , self .value )
891885
892886
893- class DSSSubpopulationAnalysis (DSSExtensibleDict ):
887+ class DSSSubpopulationAnalysis (DSSInternalDict ):
894888 """
895889 Object to read details of a subpopulation analysis of a trained model
896890
@@ -942,22 +936,16 @@ def get_modality_data(self, definition=None):
942936 if isinstance (definition , DSSSubpopulationModalityDefinition ):
943937 modality_candidates = [m for m in self .modalities if m .definition .index == definition .index ]
944938 if len (modality_candidates ) == 0 :
945- raise ValueError ("Modality with index '%s' not found" % modality [ " index" ] )
939+ raise ValueError ("Modality with index '%s' not found" % definition . index )
946940 return modality_candidates [0 ]
947941
948942 for m in self .modalities :
949943 if m .definition .contains (definition ):
950944 return m
951945 raise ValueError ("Modality not found: %s" % definition )
952946
953- def get_raw (self ):
954- """
955- Gets the raw dictionary of the subpopulation analysis
956- """
957- return self .internal_dict
958-
959947
960- class DSSSubpopulationAnalyses (DSSExtensibleDict ):
948+ class DSSSubpopulationAnalyses (DSSInternalDict ):
961949 """
962950 Object to read details of subpopulation analyses of a trained model
963951
@@ -971,12 +959,6 @@ def __init__(self, data, prediction_type):
971959 for analysis in data .get ("subpopulationAnalyses" , []):
972960 self .analyses .append (DSSSubpopulationAnalysis (analysis , prediction_type ))
973961
974- def get_raw (self ):
975- """
976- Gets the raw dictionary of subpopulation analyses
977- """
978- return self .internal_dict
979-
980962 def get_global (self ):
981963 """
982964 Retrieves information and performance on the full dataset used to compute the subpopulation analyses
@@ -987,19 +969,19 @@ def list_analyses(self):
987969 """
988970 Lists all features on which subpopulation analyses have been computed
989971 """
990- return [analysis [ "feature" ] for analysis in self .analyses ]
972+ return [analysis . get ( "feature" ) for analysis in self .analyses ]
991973
992974 def get_analysis (self , feature ):
993975 """
994976 Retrieves the subpopulation analysis for a particular feature
995977 """
996978 try :
997- return next (analysis for analysis in self .analyses if analysis [ "feature" ] == feature )
979+ return next (analysis for analysis in self .analyses if analysis . get ( "feature" ) == feature )
998980 except StopIteration :
999981 raise ValueError ("Subpopulation analysis for feature '%s' cannot be found" % feature )
1000982
1001983
1002- class DSSPartialDependence (DSSExtensibleDict ):
984+ class DSSPartialDependence (DSSInternalDict ):
1003985 """
1004986 Object to read details of partial dependence of a trained model
1005987
@@ -1019,14 +1001,8 @@ def get_computation_params(self):
10191001 "onSample" : self .get ("onSample" )
10201002 }
10211003
1022- def get_raw (self ):
1023- """
1024- Gets the raw dictionary of the partial dependence
1025- """
1026- return self .internal_dict
1027-
10281004
1029- class DSSPartialDependencies (DSSExtensibleDict ):
1005+ class DSSPartialDependencies (DSSInternalDict ):
10301006 """
10311007 Object to read details of partial dependencies of a trained model
10321008
@@ -1039,24 +1015,18 @@ def __init__(self, data):
10391015 for pd in data .get ("partialDependencies" , []):
10401016 self .partial_dependencies .append (DSSPartialDependence (pd ))
10411017
1042- def get_raw (self ):
1043- """
1044- Gets the raw dictionary of partial dependencies
1045- """
1046- return self .internal_dict
1047-
10481018 def list_features (self ):
10491019 """
10501020 Lists all features on which partial dependencies have been computed
10511021 """
1052- return [partial_dep [ "feature" ] for partial_dep in self .partial_dependencies ]
1022+ return [partial_dep . get ( "feature" ) for partial_dep in self .partial_dependencies ]
10531023
10541024 def get_partial_dependence (self , feature ):
10551025 """
10561026 Retrieves the partial dependencies for a particular feature
10571027 """
10581028 try :
1059- return next (pd for pd in self .partial_dependencies if pd [ "feature" ] == feature )
1029+ return next (pd for pd in self .partial_dependencies if pd . get ( "feature" ) == feature )
10601030 except StopIteration :
10611031 raise ValueError ("Partial dependence for feature '%s' cannot be found" % feature )
10621032
0 commit comments