예제 #1
0
 def get_submission_from_json(
         cls, submission_json: Dict) -> dist.LogisticMixture:
     components = [
         cls.get_logistic_from_json(logistic_json)
         for logistic_json in submission_json
     ]
     probs = [logistic_json["w"] for logistic_json in submission_json]
     return dist.LogisticMixture(components, probs)
예제 #2
0
    def prepare_logistic_mixture(
            self,
            normalized_dist: dist.LogisticMixture) -> dist.LogisticMixture:
        """
        Transform a (normalized) logistic mixture distribution as
        needed for submission to Metaculus.

        :param normalized_dist: normalized mixture dist
        :return: normalized dist clipped and formatted for the API
        """
        transformed_components = [
            self.prepare_logistic(c) for c in normalized_dist.components
        ]
        transformed_probs = onp.clip(normalized_dist.probs, 0.01,
                                     0.99)  # type: ignore
        return dist.LogisticMixture(transformed_components,
                                    transformed_probs)  # type: ignore