num of required transactions in [ ]len(itemsetsout[ ] so we get whopping , itemsets for support of only %this will increase exponentially if we decrease the support or if we increase the number of items in our dataset the next step is specifying confidence value and generating our rules we have written code snippet that will take confidence value and generate the rules that fulfill our specified support and confidence criteria the rules generated are then decoded using the mapping and variable names orange -associate also provides helper function that will help us extract metrics about each of these rules the following code snippet will perform rule generation and decoding of rulesand then compile it all in neat dataframe that we can use for further analysis confidence rules_df pd dataframe(if len(itemsets rules [(pqsuppconffor pqsuppconf in association_rules(itemsetsconfidenceif len( = names {item'{}={}format(var namevalfor itemvarval in onehot decode(mappingdata_gro_ mapping)eligible_ante [ for , in names items(if endswith(" ") input_assoc_rules shape[ rule_stats list(rules_stats(rulesitemsetsn)rule_list_df [for ex_rule_frm_rule_stat in rule_statsante ex_rule_frm_rule_stat[ cons ex_rule_frm_rule_stat[ named_cons names[next(iter(cons))if named_cons in eligible_anterule_lhs [names[ ][:- for in ante if names[iin eligible_anteante_rule 'join(rule_lhsif ante_rule and len(rule_lhs)> rule_dict {'supportex_rule_frm_rule_stat[ ]'confidenceex_rule_frm_rule_stat[ ]'coverageex_rule_frm_rule_stat[ ]'strengthex_rule_frm_rule_stat[ ]'liftex_rule_frm_rule_stat[ ]'leverageex_rule_frm_rule_stat[ ]'antecedent'ante_rule'consequent':named_cons[:- rule_list_df append(rule_dictrules_df pd dataframe(rule_list_dfprint("raw rules data frame of {rules generatedformat(rules_df shape[ ])if not rules_df emptypruned_rules_df rules_df groupby(['antecedent','consequent']max(reset_index(elseprint("unable to generate any rule"raw rules data frame of rules generated