Skip to content

Commit ca34644

Browse files
committed
utils: improve __repr__ output for some classes
1 parent 4f01217 commit ca34644

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

dataikuapi/dss/ml.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ def get_raw(self):
846846
return self._internal_dict
847847

848848
def __repr__(self):
849-
return self.__class__.__name__ + "(" + self._internal_dict.__repr__() + ")"
849+
return "{cls}(prediction_type={type})".format(cls=self.__class__.__name__, type=self.prediction_type)
850850

851851
def get_performance_metrics(self):
852852
"""
@@ -903,7 +903,12 @@ def get_raw(self):
903903
return self._internal_dict
904904

905905
def __repr__(self):
906-
return self.__class__.__name__ + "(" + self._internal_dict.__repr__() + ")"
906+
computed_as_type = "CATEGORY" if isinstance(self.definition, DSSSubpopulationCategoryModalityDefinition) else 'NUMERIC'
907+
return "{cls}(prediction_type={type}, feature={feature}, computed_as={computed_as_type})".format(
908+
cls=self.__class__.__name__,
909+
type=self.prediction_type,
910+
feature=self.definition.feature_name,
911+
computed_as_type=computed_as_type)
907912

908913
def get_definition(self):
909914
"""
@@ -1033,7 +1038,11 @@ def get_raw(self):
10331038
return self._internal_dict
10341039

10351040
def __repr__(self):
1036-
return self.__class__.__name__ + "(" + self._internal_dict.__repr__() + ")"
1041+
return "{cls}(computed_as_type={type}, feature={feature}, modalities_count={modalities_count})".format(
1042+
cls=self.__class__.__name__,
1043+
type=self.computed_as_type,
1044+
feature=self._internal_dict["feature"],
1045+
modalities_count=len(self.modalities))
10371046

10381047
def get_computation_params(self):
10391048
"""
@@ -1110,8 +1119,9 @@ def get_raw(self):
11101119
return self._internal_dict
11111120

11121121
def __repr__(self):
1113-
return self.__class__.__name__ + "(" + self._internal_dict.__repr__() + ")"
1114-
1122+
return "{cls}(prediction_type={type}, analyses={analyses})".format(cls=self.__class__.__name__,
1123+
type=self.prediction_type,
1124+
analyses=self.list_analyses)
11151125
def get_global(self):
11161126
"""
11171127
Retrieves information and performance on the full dataset used to compute the subpopulation analyses
@@ -1156,7 +1166,7 @@ def get_raw(self):
11561166
return self._internal_dict
11571167

11581168
def __repr__(self):
1159-
return self.__class__.__name__ + "(" + self._internal_dict.__repr__() + ")"
1169+
return "{cls}(feature={feature})".format(cls=self.__class__.__name__, feature=self._internal_dict["feature"])
11601170

11611171
def get_computation_params(self):
11621172
"""
@@ -1194,7 +1204,7 @@ def get_raw(self):
11941204
return self._internal_dict
11951205

11961206
def __repr__(self):
1197-
return self.__class__.__name__ + "(" + self._internal_dict.__repr__() + ")"
1207+
return "{cls}(features={features})".format(cls=self.__class__.__name__, features=self.list_features())
11981208

11991209
def list_features(self):
12001210
"""

0 commit comments

Comments
 (0)