def to_dict()

in src/fmeval/eval_algorithms/util.py [0:0]


    def to_dict(self) -> OrderedDict[str, Union[str, float, int, List]]:
        """
        Returns a dictionary representation of this instance,
        to be used when writing this object to JSON Lines.

        Note that we use an OrderedDict to maintain consistency
        in the ordering of columns. The score columns always come
        at the end, and the non-score columns are ordered according
        to constants.COLUMN_NAMES.
        """
        json_obj = OrderedDict(
            (col_name, self.dataset_columns[col_name])
            for col_name in DATASET_COLUMNS
            if col_name in self.dataset_columns
        )
        json_obj["scores"] = [
            # filter out None "value" and None "error"
            {k: v for k, v in eval_score.__dict__.items() if v is not None}
            for eval_score in self.scores
        ]
        return json_obj