You are on page 1of 11

JSS MAHAVIDYAPEETHA

JSS ACADEMY OF TECHNICAL EDUCATION


Affiliated to Visvesvaraya Technological University, Belagavi, Karnataka, INDIA
Approved by All India Council for Technical Education, New Delhi
UG programs accredited by NBA: ECE, CSE, ISE, CIVIL, MECHANICAL, IEM, E & IE

Data Mining and Data Warehousing


SUBCODE : 18CS641

TITLE : Implementation of Apriori & FP Growth Algorithm

Name of the student with USN:

• Amrit Baranwal : 1JS20CS026

Branch and Section : CSE ’A’

Semester : 6th

Name of the faculty : Dr Mallikarjuna P B

Signature of Faculty(s):

Remarks if any:
JSS MAHAVIDYAPEETHA
JSS ACADEMY OF TECHNICAL EDUCATION
Affiliated to Visvesvaraya Technological University, Belagavi, Karnataka, INDIA
Approved by All India Council for Technical Education, New Delhi
UG programs accredited by NBA: ECE, CSE, ISE, CIVIL, MECHANICAL, IEM, E & IE

• Implement Apriori algorithm using python and test the algorithm with
datasets.

Code:
JSS MAHAVIDYAPEETHA
JSS ACADEMY OF TECHNICAL EDUCATION
Affiliated to Visvesvaraya Technological University, Belagavi, Karnataka, INDIA
Approved by All India Council for Technical Education, New Delhi
UG programs accredited by NBA: ECE, CSE, ISE, CIVIL, MECHANICAL, IEM, E & IE
JSS MAHAVIDYAPEETHA
JSS ACADEMY OF TECHNICAL EDUCATION
Affiliated to Visvesvaraya Technological University, Belagavi, Karnataka, INDIA
Approved by All India Council for Technical Education, New Delhi
UG programs accredited by NBA: ECE, CSE, ISE, CIVIL, MECHANICAL, IEM, E & IE

Explanation:
The Apriori algorithm is a classic algorithm used for association rule mining, which is a technique to
discover interesting relationships or patterns in large datasets. The algorithm identifies frequent
itemsets from a transactional dataset, where an itemset refers to a collection of items that appear
together in transactions. The frequent itemsets are then used to generate association rules.

Here's a basic explanation of the Apriori algorithm:

Generating frequent itemsets:

• Initialize the algorithm with a minimum support threshold, which defines the minimum
frequency an itemset must have to be considered frequent.

• Scan the transactional dataset to count the occurrences of individual items. These counts are
used to determine the frequent 1-itemsets.

• Join the frequent 1-itemsets to generate candidate 2-itemsets and count their occurrences
in the dataset.

• Continue this process iteratively, joining the frequent (k-1)-itemsets to generate candidate
kitemsets until no more frequent itemsets can be found.

Generating association rules:

• For each frequent itemset, generate all possible non-empty subsets of items.
• For each subset, calculate the confidence of the corresponding association rule. The
confidence is the ratio of the support of the frequent itemset to the support of the subset.

• Select the association rules that satisfy a minimum confidence threshold.


Steps:

• Preprocess the data: Convert the transaction data into the required format for the Apriori
algorithm. This typically involves transforming the data into a list of sets, where each set
contains the unique items present in a transaction.
JSS MAHAVIDYAPEETHA
JSS ACADEMY OF TECHNICAL EDUCATION
Affiliated to Visvesvaraya Technological University, Belagavi, Karnataka, INDIA
Approved by All India Council for Technical Education, New Delhi
UG programs accredited by NBA: ECE, CSE, ISE, CIVIL, MECHANICAL, IEM, E & IE

• Generate frequent itemsets: Start with individual items as frequent itemsets and iteratively
generate larger itemsets based on their support. Scan the transactions to count the
occurrences of each itemset and filter out infrequent itemsets.
• Generate association rules: Based on the frequent itemsets obtained in the previous step,
generate association rules by considering different confidence thresholds. Calculate the
confidence of each rule and filter out those that do not meet the threshold.

OUTPUT:
JSS MAHAVIDYAPEETHA
JSS ACADEMY OF TECHNICAL EDUCATION
Affiliated to Visvesvaraya Technological University, Belagavi, Karnataka, INDIA
Approved by All India Council for Technical Education, New Delhi
UG programs accredited by NBA: ECE, CSE, ISE, CIVIL, MECHANICAL, IEM, E & IE
JSS MAHAVIDYAPEETHA
JSS ACADEMY OF TECHNICAL EDUCATION
Affiliated to Visvesvaraya Technological University, Belagavi, Karnataka, INDIA
Approved by All India Council for Technical Education, New Delhi
UG programs accredited by NBA: ECE, CSE, ISE, CIVIL, MECHANICAL, IEM, E & IE

• Implement FP growth algorithm using python and test the algorithm with
datasets

Code:
JSS MAHAVIDYAPEETHA
JSS ACADEMY OF TECHNICAL EDUCATION
Affiliated to Visvesvaraya Technological University, Belagavi, Karnataka, INDIA
Approved by All India Council for Technical Education, New Delhi
UG programs accredited by NBA: ECE, CSE, ISE, CIVIL, MECHANICAL, IEM, E & IE
JSS MAHAVIDYAPEETHA
JSS ACADEMY OF TECHNICAL EDUCATION
Affiliated to Visvesvaraya Technological University, Belagavi, Karnataka, INDIA
Approved by All India Council for Technical Education, New Delhi
UG programs accredited by NBA: ECE, CSE, ISE, CIVIL, MECHANICAL, IEM, E & IE

Explanation:
The FP-Growth algorithm is a powerful algorithm used for frequent itemset mining, similar to the
Apriori algorithm. However, FP-Growth is generally more efficient in terms of runtime, especially
for large datasets. It uses a data structure called the FP-tree (Frequent Pattern tree) to represent
the dataset and mine frequent itemsets. The algorithm consists of two main steps: building the
FPtree and mining frequent itemsets.

Here's a basic explanation of the FP Growth algorithm:

Building the FP-tree:

• Scan the transactional dataset to count the occurrences of individual items.


• Sort the items in descending order of their frequencies, creating a header table to keep track
of the positions of items in the FP-tree.

• For each transaction, remove the infrequent items and sort the remaining items based on
their frequencies.

• Construct the FP-tree by inserting the sorted items into the tree, updating the header table
accordingly.

Mining frequent itemsets:

• Start with the least frequent item from the header table and grow a conditional pattern base
for that item.

• For each item in the conditional pattern base, create a conditional FP-tree by removing the
prefix corresponding to the current item.

• Recursively mine the conditional FP-tree to find frequent itemsets, building the conditional
pattern base and conditional FP-tree for each item.

• Continue this process until no more frequent itemsets can be found.


JSS MAHAVIDYAPEETHA
JSS ACADEMY OF TECHNICAL EDUCATION
Affiliated to Visvesvaraya Technological University, Belagavi, Karnataka, INDIA
Approved by All India Council for Technical Education, New Delhi
UG programs accredited by NBA: ECE, CSE, ISE, CIVIL, MECHANICAL, IEM, E & IE

Steps:

• Preprocess the data: Convert the transaction data into the required format for the FP-
growth algorithm. This typically involves transforming the data into a list of sets, where each
set contains the unique items present in a transaction.

• Build the FP-tree: Create the FP-tree data structure by scanning the transactions and
constructing the tree nodes and links between them. Each node in the tree represents an
item, and the links between nodes represent the frequency of itemsets.
• Mine frequent itemsets: Traverse the FP-tree to extract frequent itemsets. Start with the
least frequent item and recursively grow itemsets by considering conditional FP-trees for
each item. Keep track of the support count of each itemset.
• Generate association rules: Based on the frequent itemsets obtained in the previous step,
generate association rules by considering different confidence thresholds. Calculate the
confidence of each rule and filter out those that do not meet the threshold.

OUTPUT:

*****************************
JSS MAHAVIDYAPEETHA
JSS ACADEMY OF TECHNICAL EDUCATION
Affiliated to Visvesvaraya Technological University, Belagavi, Karnataka, INDIA
Approved by All India Council for Technical Education, New Delhi
UG programs accredited by NBA: ECE, CSE, ISE, CIVIL, MECHANICAL, IEM, E & IE

You might also like