njk
njk

Reputation: 655

Clustering before classification in Weka

The instances in my dataset have multiple numeric attributes and a binary class. In Weka is there a way to use a clusterer and pass the result to a classifier (say SMO) to improve the results of classification?

Upvotes: 3

Views: 2076

Answers (2)

knb
knb

Reputation: 9295

In Weka Explorer, after loading your dataset

  • choose the Preprocess tab,
  • click "Choose..." Button,
  • add the unsupervised-attribute-filter "AddCluster".
  • click next to button, to open the Clusterer Selection field, choose a clusterer,
  • configure/parameterize the clusterer
  • close all modal dialog boxes

Click "Apply" button to apply the filter. It will add another attribute called "cluster" as the rightmost one in your attribute list.

Then continue with your classification experiments.

Upvotes: 1

Matthew Spencer
Matthew Spencer

Reputation: 2295

One way that you could add cluster information to your data is using the below method (in Weka Explorer):

  1. Load your Favourite Dataset
  2. Choose your Cluster Model (In my case, I used SimpleKMeans)
  3. Modify the Parameters of the Clusterer as Required
  4. Use the Training Set for the Cluster Mode
  5. Start the Clustering Process
  6. Once the Clusters have been generated, Right-Click on the Result List and select 'Visualize Cluster Assignments'
  7. Select Y to be the Cluster, then hit the Save Button as shown below:

Weka Cluster Visualize

  1. Save the Data to a nominated location.

You should then be able to load this file and use the cluster information in your classifier just like any other attribute. Just make sure that the Class is set to the right attribute and you should be right to go.

NOTE: When I ran these tests I used J48 to evaluate the class, and it seemed that J48 used only the values of the clusters to estimate the class. The accuracy of the model was also surprisingly high as well, so either the dataset was either too simple or I may have missed a step somewhere in the clustering process.

Hope this Helps!

Upvotes: 2

Related Questions