def association_set(self, input_data,
                        k=DEFAULT_K, score_by=None, by_name=True):
        """Returns the Consequents for the rules whose LHS best match
           the provided items. Cosine similarity is used to score the match.

            @param inputs dict map of input data: e.g.
                               {"petal length": 4.4,
                                "sepal length": 5.1,
                                "petal width": 1.3,
                                "sepal width": 2.1,
                                "species": "Iris-versicolor"}
            @param k integer Maximum number of item predictions to return
                             (Default 100)
            @param max_rules integer Maximum number of rules to return per item
            @param score_by Code for the metric used in scoring
                            (default search_strategy)
                leverage
                confidence
                support
                lhs-cover
                lift

            @param by_name boolean If True, input_data is keyed by field
                                   name, field_id is used otherwise.
        """
        predictions = {}
        if score_by and score_by not in SCORES:
            raise ValueError("The available values of score_by are: %s" %
                             ", ".join(SCORES))
        input_data = self.filter_input_data(input_data, by_name=by_name)
        # retrieving the items in input_data
        items_indexes = [item.index for item in
                         self.get_items(input_map=input_data)]
        if score_by is None:
            score_by = self.search_strategy

        for rule in self.rules:
            # checking that the field in the rhs is not in the input data
            field_type = self.fields[self.items[rule.rhs[0]].field_id][ \
                'optype']
            # if the rhs corresponds to a non-itemized field and this field
            # is already in input_data, don't add rhs
            if field_type in NO_ITEMS and self.items[rule.rhs[0]].field_id in \
                    input_data:
                continue
            # if an itemized content is in input_data, don't add it to the
            # prediction
            if field_type not in NO_ITEMS and rule.rhs[0] in items_indexes:
                continue
            cosine = sum([1 for index in items_indexes \
                if index in rule.lhs])
            if cosine > 0:
                cosine = cosine / float(math.sqrt(len(items_indexes)) * \
                                        math.sqrt(len(rule.lhs)))

                rhs = tuple(rule.rhs)
                if rhs not in predictions:
                    predictions[rhs] = {"score": 0}
                predictions[rhs]["score"] += cosine * getattr(
                    rule, score_by)
        # choose the best k predictions
        k = len(predictions.keys()) if k is None else k
        predictions = sorted(predictions.items(),
                             key=lambda x: x[1]["score"], reverse=True)[:k]
        final_predictions = []
        for rhs, prediction in predictions:
            prediction["item"] = self.items[rhs[0]].to_json()
            final_predictions.append(prediction)
        return final_predictions
dataset/ETHPy150Open bigmlcom/python/bigml/association.py/Association.association_set/original