in src/responsibleai/rai_analyse/_score_card/_rai_insight_data.py [0:0]
def __init__(self, raiinsightdata, config):
self.data = raiinsightdata
self.config = config
self.primary_metric = next(iter(self.config["Metrics"].keys()), None)
self.metrics = self.config["Metrics"].keys()
self.tasktype = (
"regression"
if self.config["Model"]["ModelType"].lower() == "regression"
else "classification"
)
self.is_multiclass = False
self.classes = None
self.pos_label = None
self.other_class = "other"
self.validate_valid_metric_for_task_type()
if self.tasktype == "classification":
self.is_multiclass = len(np.unique(self.data.get_y_test())) > 2
self.classes = self.data.get_raiinsight()._classes
self.pos_label = self.classes[1]
if self.is_multiclass:
is_numeric_label = False
self.pos_label = str(self.classes[0])
if type(self.pos_label) not in [int, str]:
raise UserConfigValidationException("Multiclass label are expected to be integers or strings.")
if isinstance(self.pos_label, int):
self.pos_label = str(self.pos_label)
is_numeric_label = True
self.classes = [self.other_class, self.pos_label]
y_pred = self.data.get_y_pred()
y_test = self.data.get_y_test()
updated_y_pred = PdfDataGen._replace_labels(y_pred, self.pos_label, self.other_class, is_numeric_label)
updated_y_test = PdfDataGen._replace_labels(y_test, self.pos_label, self.other_class, is_numeric_label)
self.data.set_y_pred(updated_y_pred)
self.data.set_y_test(updated_y_test)