@classmethod
    def error_weighted(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 prediction combining votes using error to compute weight

           If with_confidences is true, the combined confidence (as the
           error weighted average of the 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.")
        top_range = 10
        result = 0.0
        median_result = 0.0
        instances = 0
        d_min = float('Inf')
        d_max = float('-Inf')
        normalization_factor = cls.normalize_error(instance, top_range)
        if normalization_factor == 0:
            if with_confidence:
                return float('nan'), 0
            else:
                return float('nan')
        if with_confidence or add_confidence:
            combined_error = 0.0
        for prediction in instance.predictions:
            result += prediction['prediction'] * prediction['_error_weight']
            if add_median:
                median_result += (prediction['median'] *
                                  prediction['_error_weight'])
            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 or add_confidence:
                combined_error += (prediction['confidence'] *
                                   prediction['_error_weight'])
            del prediction['_error_weight']
        if with_confidence:
            return (normalization_factor / result,
                    combined_error / normalization_factor)
        if (add_confidence or add_distribution or add_count or
                add_median or add_min or add_max):
            output = {'prediction': result / normalization_factor}
            if add_confidence:
                output.update({'confidence':
                               combined_error / normalization_factor})
            if add_distribution:
                output.update(cls.grouped_distribution(instance))
            if add_count:
                output.update({'count': instances})
            if add_median:
                output.update({'median': median_result / normalization_factor})
            if add_min:
                output.update(
                    {'min': d_min})
            if add_max:
                output.update(
                    {'max': d_max})
            return output
        return result / normalization_factor
dataset/ETHPy150Open bigmlcom/python/bigml/multivote.py/MultiVote.error_weighted/swapped operands of `/`