def get_data_explorer_data()

in src/responsibleai/rai_analyse/_score_card/_rai_insight_data.py [0:0]


    def get_data_explorer_data(self):
        de_data = []
        y_test = self.data.get_y_test()
        y_predict = self.data.get_y_pred()

        for feature in self.config["DataExplorer"]["features"]:
            if feature not in self._get_feature_names():
                raise UserConfigValidationException(
                    f"Feature {feature} not found in the dataset. "
                    "Please check the feature names specified for 'DataExplorer'."
                )

            label_list, new_labels = self.get_binning_information(feature)
            counts = new_labels.value_counts()
            total = len(new_labels)
            primary_metric = self.primary_metric

            data = {
                "feature_name": feature,
                "primary_metric": primary_metric,
                "data": [],
            }

            da_labels_generator = AlphabetLabelIterator()

            for label in label_list:
                index_filter = [True if x == label else False for x in new_labels]

                f_data = {
                    "label": label,
                    "short_label": next(da_labels_generator),
                    "population": counts[label] / total,
                    "prediction": y_predict[index_filter],
                }

                if primary_metric:
                    f_data[primary_metric] = get_metric(
                        primary_metric,
                        y_predict[index_filter],
                        y_test[index_filter],
                        **self.get_metric_kwargs(),
                    )

                data["data"].append(f_data)

            de_data.append(data)

        return de_data