У меня есть следующий набор данных.
Age,Height,Weight,Medal
24,180,80,No Medal
23,170,60,No Medal
24,177,73,No Medal
34,182,96,Gold
Я использую библиотеку aprori из apyori import apriori.
Теперь я использую следующий код. Я создаю список списков.
for i in range(0, len(dataframe)):
records.append([str(dataframe.values[i, j]) for j in range(0, 4)])
association_rules = apriori(records, min_support=0.0045, min_confidence=0.2, min_lift=3, min_length=2)
association_results = list(association_rules)
for item in association_results:
# first index of the inner list
# Contains base item and add item
pair = item[0]
items = [x for x in pair]
print("Rule: " + items[0] + " -> " + items[1])
# second index of the inner list
print("Support: " + str(item[1]))
# third index of the list located at 0th
# of the third index of the inner list
print("Confidence: " + str(item[2][0][2]))
print("Lift: " + str(item[2][0][3]))
print("=====================================")
Однако я получаю следующие результаты.
Rule: 171 -> 18
Support: 0.007242940288855357
Confidence: 0.6970954356846474
Lift: 8.665127883550587
=====================================
Rule: 171 -> 61
Support: 0.009312351799956887
Confidence: 0.8888888888888888
Lift: 11.049184232463976
Rule: 171 -> No Medal
Support: 0.04850183229144212
Confidence: 0.7560483870967741
Lift: 9.397932657400684
Я хочу добиться следующего результата. Например
Rule 171 && 61 -> Gold
Следствие только медальный результат. Что я должен изменить?