DMData Mining Techniques
All experiments

Experiment 04

Association Rule Mining in WEKA

Aim

To understand and implement Association Rule Mining using the WEKA data mining tool.

Procedure

Step 1: Prepare the Dataset

  • Format: CSV or ARFF (ARFF is preferred for WEKA).
  • The dataset should contain nominal (categorical) attributes.
  • Example shopping dataset:
MilkBreadButter
YesYesNo
YesYesYes
NoYesYes
YesNoYes
NoYesNo

Save this file as basket.csv or basket.arff.

Step 2: What is arff? how to create arff file ?

An ARFF file stands for Attribute-Relation File Format — it's a text file format used by WEKA to store datasets.

Structure of an ARFF File

An ARFF file has two main parts:

A. Header Section

Describes the dataset:

  • @relation — name of the dataset.
  • @attribute — each column (name + data type).
  • Data types can be:
    • numeric (numbers)
    • string (text)
    • {value1, value2,...} (nominal/categorical values)
    • date (with optional format)

B. Data Section

  • Starts with @data.
  • Each row = one instance/record.
  • Values are separated by commas.

Example

@relation market_basket

@attribute Milk {t,f}
@attribute Bread {t,f}
@attribute Butter {t,f}
@attribute Jam {t,f}
@attribute Eggs {t,f}

@data
t, t, t, f, f
t, f, t, t, f
t, t, f, f, t
f, t, t, f, f
t, t, t, f, t
f, f, t, t, f

Nominal attributes (categorical) must list all possible values in {}.

For numeric data:

@attribute Age numeric
  • No spaces in attribute names (use underscores instead).
  • Missing values are represented by a ?.

Step 3. How to Create an ARFF File

You can create it in any text editor.

  1. Open a text editor (Notepad, VS Code, etc.)..
  2. Write the header (@relation, @attribute lines).
  3. Add the @data line.
  4. Enter your dataset values row-by-row.
  5. Save the file with .arff extension (e.g., basket.arff).
  6. Load it into WEKA.

Step 4: Load the Dataset in WEKA

  1. Open WEKA GUI Chooser → Explorer.
  2. Click 'Open file' → select your basket.arff dataset.
  3. View attributes and instances under the Preprocess tab.

Step 5: Run the Apriori Algorithm

  1. Go to the Associate tab.
  2. From the list of algorithms, choose: weka.associations.Apriori.
  3. Click 'Start' to run the algorithm.
  4. Observe the generated association rules in the result panel.

Step 6: Interpret the Results

Example Output Rule:

Bread=Yes ⇒ Butter=Yes conf:(0.75)

This means when 'Bread' is purchased, 'Butter' is also purchased 75% of the time.

Output

Association Rule Mining in WEKA output screenshot 1Association Rule Mining in WEKA output screenshot 2

Result

The experiment was successfully executed, and the expected output was obtained using WEKA.