@classmethod
    def avg(cls, instance, with_confidence=False,
            add_confidence=False, add_distribution=False,
            add_count=False, add_median=False, add_min=False, add_max=False):
        """Returns the average of a list of numeric values.

           If with_confidence is True, the combined confidence (as the
           average of confidences of the multivote predictions) is also
           returned
        """
        if (instance.predictions and with_confidence and
                not all(['confidence' in prediction
                         for prediction in instance.predictions])):
            raise Exception("Not enough data to use the selected "
                            "prediction method. Try creating your"
                            " model anew.")
        total = len(instance.predictions)
        result = 0.0
        median_result = 0.0
        confidence = 0.0
        instances = 0
        d_min = float('Inf')
        d_max = float('-Inf')
        for prediction in instance.predictions:
            result += prediction['prediction']
            if add_median:
                median_result += prediction['median']
            if with_confidence or add_confidence:
                confidence += prediction['confidence']
            if add_count:
                instances += prediction['count']
            if add_min and d_min > prediction['min']:
                d_min = prediction['min']
            if add_max and d_max < prediction['max']:
                d_max = prediction['max']
        if with_confidence:
            return (result / total, confidence / total) if total > 0 else \
                (float('nan'), 0)
        if (add_confidence or add_distribution or add_count or
                add_median or add_min or add_max):
            output = {'prediction': result / total if total > 0 else \
                float('nan')}
            if add_confidence:
                output.update(
                    {'confidence': total / confidence if total > 0 else 0})
            if add_distribution:
                output.update(cls.grouped_distribution(instance))
            if add_count:
                output.update({'count': instances})
            if add_median:
                output.update(
                    {'median': median_result / total if total > 0 else \
                    float('nan')})
            if add_min:
                output.update(
                    {'min': d_min})
            if add_max:
                output.update(
                    {'max': d_max})
            return output
        return result / total if total > 0 else float('nan')
dataset/ETHPy150Open bigmlcom/python/bigml/multivote.py/MultiVote.avg/swapped operands of `/`