

























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


























Practice Question Bank & Answer Rationale
THIS PACK CONTAINS 99 exam-style multiple-choice questions. Each question includes the correct answer and a complete rationale for focused revision.
COVERAGE This exam assesses mastery of market basket analysis and association rule mining, focusing on the Apriori algorithm, frequent itemset generation, rule evaluation metrics (support, confidence, lift), and Python implementation using libraries such as mlxtend and apyori. Students must demonstrate the ability to preprocess transactional data, generate and interpret association rules, and apply these techniques to real-world business scenarios.
STUDY GUIDE Recommended duration: 3 hours. Passing target: 80%.
CORRECT: B. 3 Support count is the number of transactions containing the itemset. {A,B} appears in transactions 1, 2, and 5, so count=3. Other counts are incorrect.
CORRECT: A. 1. Lift = confidence / support(B) = 0.8 / 0.5 = 1.6. This indicates a positive association. Other options misapply the formula.
[ ] A. They must be frequent. [ ] B. They must be infrequent. [ ] C. They may or may not be frequent. [ ] D. They have higher support.
CORRECT: B. They must be infrequent. Apriori's downward closure property states that all supersets of an infrequent itemset are also infrequent. This is fundamental for pruning. Other options contradict this principle.
[ ] A. apriori from mlxtend.frequent_patterns [ ] B. association_rules from apyori [ ] C. frequent_patterns from sklearn [ ] D. itemsets from pandas
[ ] A. To prune infrequent itemsets [ ] B. To create new itemsets from frequent ones [ ] C. To calculate support of rules [ ] D. To filter transactions
CORRECT: B. To create new itemsets from frequent ones Candidate generation creates new itemsets by joining frequent itemsets from the previous iteration. Pruning occurs in a separate step. Other options describe different phases.
[ ] A. Support=0.25, Confidence=0. [ ] B. Support=0.35, Confidence=0. [ ] C. Support=0.4, Confidence=0. [ ] D. Support=0.2, Confidence=0.
CORRECT: C. Support=0.4, Confidence=0. Only rule C meets both thresholds: support 0.4 0.3 and confidence 0.75 0.7. Others fail at least one threshold.
[ ] A. All subsets of a frequent itemset are frequent. [ ] B. All supersets of a frequent itemset are frequent. [ ] C. All subsets of an infrequent itemset are infrequent. [ ] D. All supersets of an infrequent itemset are infrequent.
CORRECT: D. All supersets of an infrequent itemset are infrequent. The Apriori property (downward closure) states that if an itemset is infrequent, all its supersets are infrequent. This allows pruning. Option A is true but not the property; B and C are false.
CORRECT: C. 0. Confidence(A->B) = support({A,B}) / support({A}) = 200/1000 ÷ 500/1000 = 200/500 = 0.40. Option A is the
support of the joint itemset, B is the support of A, and D is the joint count divided by 1000 twice.
[ ] D. No candidate is generated
CORRECT: A. {A,B,C,D} Apriori joins two frequent k-itemsets that share k1 items; {A,B,C} and {A,B,D} share {A,B}, so the join yields {A,B,C,D}. The other options are not valid joins because they are not 4-itemsets or do not share the required prefix.
[ ] A. A and B are positively correlated [ ] B. A and B are independent [ ] C. A and B are negatively correlated [ ] D. A implies B with certainty
CORRECT: B. A and B are independent Lift = confidence(A->B)/support(B). Lift = 1 means confidence equals the baseline support of B, so A provides no information about B; they are statistically independent. Lift >1 indicates positive correlation, <1 negative, and confidence 1.0 (not lift) would indicate certainty.
[ ] A. association_rules [ ] B. frequent_itemsets [ ] C. TransactionEncoder().fit [ ] D. OneHotEncoder
CORRECT: C. TransactionEncoder().fit mlxtend's TransactionEncoder().fit (or fit_transform) converts list-of-transactions or one-hot DataFrames into the boolean transaction matrix expected by apriori. association_rules and frequent_itemsets operate after mining, and OneHotEncoder is a scikit-learn transformer not used for this purpose.
[ ] D. Discretizing continuous quantities
CORRECT: B. Removing identifier columns before encoding Transaction IDs are unique per row and would create rules with perfect confidence but no business meaning, so identifier columns must be dropped before one-hot encoding. Price normalization, imputation, and discretization address different data-quality issues and do not remove spurious ID-based associations.
[ ] A. A guarantees B and is actionable [ ] B. B always occurs, so A adds no information [ ] C. A and B are perfectly correlated [ ] D. The rule is invalid due to zero support
CORRECT: B. B always occurs, so A adds no information Confidence 1.0 means every transaction with A also has B, but lift 1.0 means B occurs at the same rate everywhere; A does not increase the likelihood of B, so the rule is trivial. Perfect correlation would require lift 1, and zero support is not implied.
[ ] A. High minimum support and low maximum itemset length [ ] B. Low minimum support and high minimum confidence [ ] C. High minimum confidence and high lift [ ] D. Low minimum support and low lift
CORRECT: A. High minimum support and low maximum itemset length Candidate explosion is controlled at the frequent-itemset stage by raising minimum support (pruning more itemsets) and capping itemset length (max_len), which limits the number of join steps. Confidence and lift are applied after frequent itemsets are found and do not reduce candidate generation.
[ ] A. Lift = 1.60; antecedent and consequent are positively associated beyond chance. [ ] B. Lift = 0.64; negative association indicating substitution. [ ] C. Lift = 0.50; independence between antecedent and consequent. [ ] D. Lift = 2.00; perfect positive association.
CORRECT: A. Lift = 1.60; antecedent and consequent are positively associated beyond chance. Lift = confidence / consequent support = 0.80 / 0.50 = 1.60. Lift > 1 indicates positive association beyond independence. Lift = 1 would indicate independence; <1 negative association.
[ ] A. Confidence monotonicity: confidence never decreases with itemset size. [ ] B. Anti-monotonicity of support: supersets cannot exceed subset support. [ ] C. Lift closure: lift is invariant under itemset extension. [ ] D. Conviction invariance: conviction is constant across supersets.
CORRECT: B. Anti-monotonicity of support: supersets cannot exceed subset support. Apriori relies on the anti-monotone property of support: if an itemset is infrequent, all its supersets are also infrequent. This enables safe pruning. Confidence and lift are not monotone in general.
[ ] A. association_rules() [ ] B. apriori() [ ] C. TransactionEncoder().fit_transform() [ ] D. frequent_itemsets()
CORRECT: C. TransactionEncoder().fit_transform() TransactionEncoder in mlxtend transforms list-of-transactions into a one-hot boolean DataFrame suitable for apriori/fpgrowth. apriori() mines itemsets; association_rules() generates rules; frequent_itemsets() is not a conversion function.
CORRECT: B. 0. {A,B} appears in transactions 1, 2, and 5: 3 out of 5 = 0.60. Support is the proportion of transactions containing the itemset.
[ ] A. X strongly promotes Y; deploy the rule. [ ] B. X and Y are independent; confidence equals consequent support. [ ] C. X is negatively associated with Y; Y is less likely given X than baseline. [ ] D. Lift < 1 is impossible with confidence 0.75.
[ ] A. A dense dataset with very long transactions and low minimum support. [ ] B. A small dataset where interpretability of candidate generation is required. [ ] C. A dataset where only maximal itemsets are needed. [ ] D. A streaming dataset requiring incremental updates per transaction.
CORRECT: A. A dense dataset with very long transactions and low minimum support. FP-Growth avoids candidate generation by building an FP-tree, making it more efficient on dense data with long transactions and low support thresholds where Apriori suffers from candidate explosion. Apriori is simpler for small datasets; neither natively handles streaming updates.
[ ] A. High confidence alone, sorted descending. [ ] B. High support alone, sorted ascending. [ ] C. High lift with adequate support and confidence thresholds. [ ] D. High conviction with minimal support to capture rare rules.
CORRECT: C. High lift with adequate support and confidence thresholds. Lift identifies genuine associations beyond chance, while support ensures the rule is frequent enough to be actionable and confidence ensures reliability. Reporting lift alone risks rare spurious rules; confidence or support alone can mislead due to frequent consequents or rare itemsets.
CORRECT: B. 0. Support(A->B) = |{A,B}| / N = 2/5 = 0.40, counting only transactions containing both A and B. 0.60 is confidence-like (2/3) and 0.80 is support of A alone; 0.20 is support of the full set {A,B,C}.
[ ] A. The antecedent and consequent are positively correlated. [ ] B. The rule is statistically significant at =0.05. [ ] C. The consequent occurs less often with the antecedent than by chance. [ ] D. The rule satisfies minimum support but not confidence.
CORRECT: C. The consequent occurs less often with the antecedent than by chance. Lift < 1 means P(consequent|antecedent) < P(consequent), so the items are negatively correlated and the antecedent reduces the consequent's likelihood. Lift does not test significance, and confidence 0.80 may still meet thresholds.
[ ] A. Confidence is monotone decreasing with itemset size. [ ] B. Support is anti-monotone: supersets cannot exceed subset support. [ ] C. Lift is invariant under itemset extension. [ ] D. Candidate generation requires all subsets to be frequent.
CORRECT: B. Support is anti-monotone: supersets cannot exceed subset support. The Apriori principle is that support is anti-monotone (downward-closed): if a 3-itemset is infrequent, every superset is also infrequent, so it can be pruned. Confidence and lift are not anti-monotone in the same way, and option D restates the rule rather than the underlying property.
[ ] A. association_rules(df, metric='support') [ ] B. TransactionEncoder().fit(df).transform(df) [ ] C. df.values.tolist() [ ] D. frequent_itemsets = apriori(df, min_support=0.1, use_colnames=True)
CORRECT: D. frequent_itemsets = apriori(df, min_support=0.1, use_colnames=True) mlxtend.frequent_patterns.apriori accepts a one-hot encoded boolean DataFrame directly and returns frequent itemsets when use_colnames=True. TransactionEncoder is used when starting from list-of-lists transactions, not one-hot data; association_rules generates rules from itemsets.
[ ] A. The consequent is globally frequent, so the rule is largely redundant. [ ] B. The antecedent is rare, inflating confidence artificially. [ ] C. The rule should be retained because confidence is the primary metric. [ ] D. The rule indicates a strong causal relationship.
CORRECT: A. The consequent is globally frequent, so the rule is largely redundant. High confidence with low lift often occurs when the consequent is common overall, so P(C|A) P(C). Such rules add little actionable information. Rare antecedents tend to inflate confidence but would typically produce high lift, and association rules do not establish causality.
CORRECT: C. Lift Lift normalizes confidence by the consequent's base rate, P(C), so ubiquitous consequents yield lift near 1 and are filtered. Support and confidence can both be high for such trivial rules; leverage also adjusts for independence but is less standard for this specific filter.
[ ] A. Lower min_confidence to surface more rules [ ] B. Rank by lift and confidence and filter by business-relevant consequents [ ] C. Increase min_support to reduce rule count [ ] D. Convert to sequential pattern mining
CORRECT: B. Rank by lift and confidence and filter by business-relevant consequents Actionability improves by ranking on lift/confidence and constraining consequents to items of business interest. Lowering confidence adds noise, raising support may discard useful niche rules, and switching to sequential mining changes the problem rather than refining the report.
[ ] A. Antecedent and consequent are nearly independent; rule adds little predictive value. [ ] B. High confidence guarantees strong positive association despite low support. [ ] C. Rule is statistically significant because confidence exceeds 0.75. [ ] D. Consequent occurs 1.05 times more often than antecedent overall.
CORRECT: A. Antecedent and consequent are nearly independent; rule adds little predictive value. Lift = confidence / support(consequent); a value near 1 means P(consequent|antecedent) P(consequent), indicating near-independence. High confidence alone can be misleading when the consequent is already frequent. Lift > 1 indicates positive association; lift = 1 is not evidence of a useful rule.
[ ] A. A superset of an infrequent itemset cannot be frequent (anti-monotonicity). [ ] B. A superset of a frequent itemset must also be frequent. [ ] C. Confidence of a rule is monotonic in itemset size. [ ] D. Lift of a rule is always greater than its confidence.
CORRECT: A. A superset of an infrequent itemset cannot be frequent (anti-monotonicity). Apriori's downward-closure (anti-monotonicity) property states that if an itemset is infrequent, all its supersets are also infrequent and can be pruned. This drastically reduces candidate generation. The other statements are false: supersets of frequent sets are not necessarily frequent; confidence and lift are not monotonic in size.
CORRECT: A. 0. Support is the fraction of transactions containing the itemset: 30/1000 = 0.03. As a percentage it is 3%. Options B and D misplace the decimal; C is the percentage expressed as a number rather than a proportion.
[ ] A. association_rules [ ] B. apriori [ ] C. frequent_patterns [ ] D. TransactionEncoder
CORRECT: B. apriori mlxtend.frequent_patterns.apriori (or fpgrowth) mines frequent itemsets from a one-hot encoded DataFrame. TransactionEncoder transforms lists into the boolean DataFrame; association_rules generates rules from frequent itemsets. frequent_patterns is the module, not the function.
CORRECT: A. 1. Lift = confidence / support(consequent) = 0.6 / 0.5 = 1.20, indicating a positive association beyond chance. Option B is the reciprocal (support/confidence), C multiplies them, and D is arbitrary.
[ ] A. Standardize numeric item quantities to z-scores. [ ] B. Encode transactions into a boolean one-hot matrix. [ ] C. Apply PCA to reduce item dimensionality. [ ] D. Impute missing values using KNN.
measures joint frequency, not association strength. Leverage is support(antecedentconsequent) support(antecedent)-support(consequent), not confidence minus support.
[ ] A. A and B are positively correlated. [ ] B. The rule is not useful because lift 1. [ ] C. The rule is strong but not interesting because lift 1. [ ] D. The rule is strong but not interesting because lift = 1 indicates independence.
CORRECT: C. The rule is strong but not interesting because lift 1. Lift = 1 indicates that A and B are independent, so the rule does not reveal a genuine association despite high confidence. Support 0.02 is low, and confidence 0.8 is high, but the lack of lift means the rule is not actionable. Options A and B are incorrect because lift = 1 is not positive correlation, and the rule is not 'not useful' solely due to lift 1; the precise interpretation is independence.
[ ] A. If an itemset is frequent, all its supersets must be frequent. [ ] B. If an itemset is infrequent, all its supersets must be infrequent. [ ] C. The property is used to generate candidate itemsets by joining frequent itemsets. [ ] D. The property ensures that support of an itemset is always greater than support of its subsets.
CORRECT: B. If an itemset is infrequent, all its supersets must be infrequent. The Apriori property (downward-closure) states that if an itemset is infrequent, all its supersets are also infrequent, allowing pruning. Option A reverses the property; frequent itemsets do not guarantee frequent supersets. Option C describes the join step, not the property itself. Option D is false because support of a superset is less than or equal to support of its subsets.
[ ] A. The maximum number of rules to generate. [ ] B. The maximum length of the itemsets to be generated. [ ] C. The maximum support threshold. [ ] D. The maximum number of transactions to process.
CORRECT: B. The maximum length of the itemsets to be generated. In mlxtend.frequent_patterns.apriori, max_len specifies the maximum size of itemsets to generate. It does not limit the number of rules (that is done later with association_rules), nor support threshold, nor transactions. This parameter is useful to reduce computation when only smaller itemsets are of interest.
CORRECT: C. 0. Confidence = support(X Y) / support(X) = (150/1000) / (300/1000) = 150/300 = 0.50. The other options miscompute by using support of the union as confidence (0.15), support of X (0.30), or an incorrect ratio (0.20).
[ ] A. Normalizing numerical transaction amounts. [ ] B. Encoding transactions as a one-hot boolean DataFrame. [ ] C. Removing duplicate items within each transaction. [ ] D. Aggregating items by category.
CORRECT: B. Encoding transactions as a one-hot boolean DataFrame. mlxtend's apriori requires a one-hot encoded boolean DataFrame where rows are transactions and columns are items. Normalizing amounts is irrelevant for association rules; removing duplicates is handled by the one-hot encoding; aggregating by category changes the analysis level and is not required.
CORRECT: A. 0. Confidence = support({A,B,C}) / support({A,B}) = 0.04 / 0.10 = 0.4. Options B and C mistakenly use the support values directly; D is an incorrect division.
[ ] A. The consequent is 2.5 times more likely when the antecedent occurs than when it does not. [ ] B. The antecedent and consequent are independent. [ ] C. The rule is not useful because lift > 1. [ ] D. The consequent is 2.5 times more likely given the antecedent than its baseline probability.
[ ] A. Lift less than 1. [ ] B. Confidence greater than 0. [ ] C. Support greater than 0. [ ] D. Conviction greater than 1.
CORRECT: A. Lift less than 1. Lift < 1 indicates that the antecedent and consequent occur together less often than expected under independence, signaling a negative association. Confidence, support, and conviction >1 do not directly reveal negative dependence; conviction >1 actually implies positive association. Thus only lift < 1 correctly identifies negative association.
[ ] A. To prune infrequent itemsets using the anti-monotonicity property [ ] B. To create new itemsets by joining frequent itemsets from the previous iteration [ ] C. To calculate the support of each itemset by scanning the database [ ] D. To generate association rules from frequent itemsets
CORRECT: B. To create new itemsets by joining frequent itemsets from the previous iteration Candidate generation (the join step) systematically combines frequent (k-1)-itemsets to produce candidate k-itemsets. Pruning (option A) is a separate step that removes candidates containing infrequent subsets; support counting (C) occurs after candidate generation; rule generation (D) follows frequent itemset mining.
CORRECT: C. 0. Support is the proportion of transactions containing the itemset. {A,B} appears in transactions 1, 2, and 5, so support = 3/5 = 0.6. The other values misrepresent the count (0.4 = 2/5, 0.2 = 1/5, 0.8 = 4/5).
[ ] A. min_support as a float [ ] B. min_support as an integer [ ] C. max_len [ ] D. low_memory
CORRECT: B. min_support as an integer In mlxtend, when min_support is provided as an integer, it is interpreted as an absolute count threshold (minimum transaction count). A float (A) specifies a proportion; max_len (C) limits itemset size; low_memory (D) affects memory usage, not support thresholding.
CORRECT: C. 2. Lift = confidence / support(consequent) = 0.8 / 0.4 = 2.0. This indicates that Y is twice as likely when X is present. Options A, B, and D result from misapplying the formula (e.g., multiplying or dividing incorrectly).
[ ] A. Normalizing numerical item quantities [ ] B. One-hot encoding transactions into a boolean matrix [ ] C. Removing duplicate items within each transaction [ ] D. Aggregating items by category
CORRECT: B. One-hot encoding transactions into a boolean matrix Apriori requires a transaction-item matrix where each row is a transaction and each column a unique item, with boolean values indicating presence. Normalizing quantities (A) is irrelevant for boolean association; removing duplicates (C) is a minor cleaning step but not the core transformation; aggregation (D) alters the item granularity and is not required.
[ ] A. Strong actionable rule due to high confidence [ ] B. Statistically significant but practically weak association [ ] C. Rule is likely spurious due to low support [ ] D. Lift indicates a strong positive correlation
CORRECT: C. Rule is likely spurious due to low support Very low support (0.02) means the rule occurs in only 2% of transactions, which may be due to chance or niche co-occurrence; high confidence can be misleading when the consequent is frequent. Lift of 1. indicates only a slight positive association, not strong correlation. Thus the rule is likely spurious or not generalizable.