def to_dict()

in eland/ml/_model_serializer.py [0:0]


    def to_dict(self) -> Dict[str, Any]:
        d: Dict[str, Any] = {}
        add_if_exists(d, "node_index", self._node_idx)
        add_if_exists(d, "decision_type", self._decision_type)
        if self._leaf_value is None:
            add_if_exists(d, "left_child", self._left_child)
            add_if_exists(d, "right_child", self._right_child)
            add_if_exists(d, "split_feature", self._split_feature)
            add_if_exists(d, "threshold", self._threshold)
            add_if_exists(d, "number_samples", self._number_samples)
            add_if_exists(d, "default_left", self._default_left)
        else:
            if len(self._leaf_value) == 1:
                # Support Elasticsearch 7.6 which only
                # singular leaf_values not in arrays
                add_if_exists(d, "leaf_value", self._leaf_value[0])
            else:
                add_if_exists(d, "leaf_value", self._leaf_value)
        return d