def combine_categorical(self, weight_label=None, with_confidence=False,
                            add_confidence=False, add_distribution=False,
                            add_count=False):
        """Returns the prediction combining votes by using the given weight:

            weight_label can be set as:
            None:          plurality (1 vote per prediction)
            'confidence':  confidence weighted (confidence as a vote value)
            'probability': probability weighted (probability as a vote value)

            If with_confidence is true, the combined confidence (as a weighted
            average of the confidences of the votes for the combined
            prediction) will also be given.
        """
        mode = {}
        instances = 0
        if weight_label is None:
            weight = 1
        for prediction in self.predictions:
            if weight_label is not None:
                if weight_label not in COMBINATION_WEIGHTS.values():
                    raise Exception("Wrong weight_label value.")
                if weight_label not in prediction:
                    raise Exception("Not enough data to use the selected "
                                    "prediction method. Try creating your"
                                    " model anew.")
                else:
                    weight = prediction[weight_label]
            category = prediction['prediction']
            if add_count:
                instances += prediction['count']
            if category in mode:
                mode[category] = {"count": mode[category]["count"] + weight,
                                  "order": mode[category]["order"]}
            else:
                mode[category] = {"count": weight,
                                  "order": prediction['order']}
        prediction = sorted(mode.items(), key=lambda x: (x[1]['count'],
                                                         -x[1]['order'],
                                                         x[0]),
                            reverse=True)[0][0]
        if with_confidence or add_confidence:
            if self.predictions[0] in 'confidence':
                prediction, combined_confidence = self.weighted_confidence(
                    prediction, weight_label)
            # if prediction had no confidence, compute it from distribution
            else:
                combined_distribution = self.combine_distribution()
                distribution, count = combined_distribution
                combined_confidence = ws_confidence(prediction, distribution,
                                                    ws_n=count)
        if with_confidence:
            return prediction, combined_confidence
        if add_confidence or add_distribution or add_count:
            output = {'prediction': prediction}
            if add_confidence:
                output.update({'confidence': combined_confidence})
            if add_distribution:
                output.update(self.__class__.grouped_distribution(self))
            if add_count:
                output.update({'count': instances})
            return output
        return prediction
dataset/ETHPy150Open bigmlcom/python/bigml/multivote.py/MultiVote.combine_categorical/swapped operands of `in`