Skip to content

Commit

Permalink
add colnames unittests to association_rules (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasbt authored Jun 5, 2018
1 parent a8e65db commit bcf3f44
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions mlxtend/frequent_patterns/tests/test_association_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

df_freq_items = apriori(df, min_support=0.6)

df_freq_items_with_colnames = apriori(df, min_support=0.6, use_colnames=True)

columns_ordered = ['antecedants', 'consequents',
'antecedent support', 'consequent support',
'support',
Expand Down Expand Up @@ -88,9 +90,43 @@ def test_leverage():
metric='leverage')
assert res_df.values.shape[0] == 6

res_df = association_rules(df_freq_items_with_colnames,
min_threshold=0.1,
metric='leverage')
assert res_df.values.shape[0] == 6


def test_conviction():
res_df = association_rules(df_freq_items,
min_threshold=1.5,
metric='conviction')
assert res_df.values.shape[0] == 11

res_df = association_rules(df_freq_items_with_colnames,
min_threshold=1.5,
metric='conviction')
assert res_df.values.shape[0] == 11


def test_lift():
res_df = association_rules(df_freq_items,
min_threshold=1.1,
metric='lift')
assert res_df.values.shape[0] == 6

res_df = association_rules(df_freq_items_with_colnames,
min_threshold=1.1,
metric='lift')
assert res_df.values.shape[0] == 6


def test_confidence():
res_df = association_rules(df_freq_items,
min_threshold=0.8,
metric='confidence')
assert res_df.values.shape[0] == 9

res_df = association_rules(df_freq_items_with_colnames,
min_threshold=0.8,
metric='confidence')
assert res_df.values.shape[0] == 9

0 comments on commit bcf3f44

Please sign in to comment.