Top Banner
WEKA IT For Business Intelligence Ishan Awadhesh 10BM60033 • Term Paper • 19 April 2012 Vinod Gupta School of Management, IIT Kharagpur 1
17

Classification and Clustering Analysis using Weka

Nov 01, 2014

Download

Education

Ishan Awadhesh

This Term Paper demonstrates the classification and clustering analysis on Bank Data using Weka. Classification Analysis is used to determine whether a particular customer would purchase a Personal Equity PLan or not while Clustering Analysis is used to analyze the behavior of various customer segments.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Classification and Clustering Analysis using Weka

WEKAIT For Business Intelligence

Ishan Awadhesh10BM60033 • Term Paper • 19 April 2012

Vinod Gupta School of Management, IIT Kharagpur 1

Page 2: Classification and Clustering Analysis using Weka

Table of Contents

WEKA! 3

Data Used! 5

Classification Analysis ! 6

Cluster Analysis! 11

Other Applications of Weka! 17

References ! 17

Vinod Gupta School of Management, IIT Kharagpur 2

Page 3: Classification and Clustering Analysis using Weka

WEKAWaikato Environment for Knowledge Analysis

DATA MINING TECHNIQUES

WEKA is a collection of state-of-the-art machine learning algorithms and data preprocessing

tools written in Java, developed at the University of Waikato, New Zealand. It is free software

that runs on almost any platform and is available under the GNU General Public License. It

has a wide range of applications in various data mining techniques. It provides extensive

support for the entire process of experimental data mining, including preparing the input

data, evaluating learning schemes statistically, and visualizing the input data and the result of

learning. The WEKA workbench includes methods for the main data mining problems:

regression, classification, clustering, association rule mining, and attribute selection. It can

be used in either of the following two interfaces –

•! Command Line Interface (CLI)

•! Graphical User Interface (GUI)

The WEKA GUI Chooser appears like this –

Vinod Gupta School of Management, IIT Kharagpur 3

Page 4: Classification and Clustering Analysis using Weka

The buttons can be used to start the following applications –

•Explorer – Environment for exploring data with WEKA. It gives access to all the

facilities using menu selection and form filling.

•Experimenter – It can be used to get the answer for a question: Which methods and

parameter values work best for the given problem?

•KnowledgeFlow – Same function as explorer. Supports incremental learning. It

allows designing configurations for streamed data processing. Incremental algorithms

can be used to process very large datasets.

•Simple CLI – It provides a simple Command Line Interface for directly executing

WEKA commands.

This term paper will demonstrate the following two data mining techniques using WEKA:

•Classification

•Clustering (Simple K Means)

Vinod Gupta School of Management, IIT Kharagpur 4

Page 5: Classification and Clustering Analysis using Weka

Data UsedThe data used in this paper is Bank Data available in Comma Separated Values format

The data contains following fields

id - a unique identification numberage - age of customer in years (numeric)sex - MALE / FEMALEregion - inner_city/rural/suburban/townincome- income of customer (numeric)married - is the customer married (YES/NO)children - number of children (numeric)car - does the customer own a car (YES/NO)save_acct - does the customer have a saving account (YES/NO)current_acct - does the customer have a current account (YES/NO)mortgage - does the customer have a mortgage (YES/NO)pep - did customer buy a PEP (Personal Equity Plan) after the last mailing (YES/NO)

Vinod Gupta School of Management, IIT Kharagpur 5

Page 6: Classification and Clustering Analysis using Weka

Classification Analysis

Question

"How likely is person X to buy the new Personal Equity?" By creating a classification tree (a

decision tree), the data can be mined to determine the likelihood of this person to buy a new

PEP. Possible nodes on the tree would be children, income level, marital status. The

attributes of this person can be used against the decision tree to determine the likelihood of

him purchasing the Personal Equity Plan.

Load the data file Bank_Data.CSV into WEKA. This file contains 900 records of present

customers of Bank.

We need to divide up our records so some data instances are used to create the model, and

some are used to test the model to ensure that we didn't overfit it.

Your screen should look like Figure 1 after loading the data.

Figure 1.Bank Data Classification in Weka

We select the Classify tab, then we select the trees node, then the J48 leaf

Vinod Gupta School of Management, IIT Kharagpur 6

Page 7: Classification and Clustering Analysis using Weka

Figure 2.Bank Data Classification Algorithm

At this point, we are ready to create our model in WEKA. Ensure that Use training set is

selected so we use the data set we just loaded to create our model. Click Start and let WEKA

run. The output from this model should look like the results in Listing 1.

Vinod Gupta School of Management, IIT Kharagpur 7

Page 8: Classification and Clustering Analysis using Weka

Listing 1.Output from WEKA’s classification model

What do these numbers mean-

Correctly Classified Instances - 92.3333%

Incorrectly Classified Instances- 7.6667%

False Positives- 29

False Negatives-17

Based on our accuracy rate of 92.3333%, we can say that this is a pretty good model to predict

whether a new customer will buy Personal Equity Plan or not.

Vinod Gupta School of Management, IIT Kharagpur 8

Page 9: Classification and Clustering Analysis using Weka

You can see the tree by right-clicking on the model you just created, in the result list. On the

pop-up menu, select Visualize tree. You'll see the classification tree we just created,

although in this example, the visual tree doesn't offer much help.

Figure 3. Classification Tree Visualization

There's one final step to validating our classification tree, which is to run our test set through

the model and ensure that accuracy of the model when evaluating the test set isn't too

different from the training set. To do this, in Test options, select the Supplied test set radio

button and click Set. Choose the file bmw-test.arff, which contains 1,500 records that were

not in the training set we used to create the model. When we click Start this time, WEKA will

run this test data set through the model we already created and let us know how the model did.

Let's do that, by clicking Start. Below is the output.

Vinod Gupta School of Management, IIT Kharagpur 9

Page 10: Classification and Clustering Analysis using Weka

Listing 2.Output from WEKA’s classification model of Test Data

Comparing the "Correctly Classified Instances" from this test set (90.5 percent) with the

"Correctly Classified Instances" from the training set (92.3333 percent), we see that the

accuracy of the model is pretty close, which indicates that the model will not break down with

unknown data, or when future data is applied to it.

Vinod Gupta School of Management, IIT Kharagpur 10

Page 11: Classification and Clustering Analysis using Weka

Cluster Analysis

Question: "What age groups more likely to buy Personal Equity Plan?" The data can be

mined to compare the age of the purchaser of past PEP . From this data, it could be found

whether certain age groups (22-30 year olds, for example) have a higher propensity to to go

for PEP. The data, when mined, will tend to cluster around certain age groups and certain

colors, allowing the user to quickly determine patterns in the data.

Load the data file Bank_data.CSV into WEKA using the same steps we used to load data into

the Preprocess tab. Take a few minutes to look around the data in this tab. Look at the

columns, the attribute data, the distribution of the columns, etc. Your screen should look like

Figure 4 after loading the data.

Figure 4. Bank cluster data in Weka

With this data set, we are looking to create clusters, so instead of clicking on the Classify tab,

click on the Cluster tab. Click Choose and select SimpleKMeans from the choices that appear

(this will be our preferred method of clustering for this article).

Vinod Gupta School of Management, IIT Kharagpur 11

Page 12: Classification and Clustering Analysis using Weka

Finally, we want to adjust the attributes of our cluster algorithm by clicking SimpleKMeans .

The only attribute of the algorithm we are interested in adjusting here is the numClusters

field, which tells us how many clusters we want to create. Let's change the default value of 2 to

5 for now, but keep these steps in mind later if you want to adjust the number of clusters

created. Your WEKA Explorer should look like Figure 5 at this point. Click OK to accept

these values.

Figure 5. Cluster Attributes

At this point, we are ready to run the clustering algorithm. Remember that 100 rows of data

with five data clusters would likely take a few hours of computation with a spreadsheet, but

WEKA can spit out the answer in less than a second. Your output should look like Listing 3.

Vinod Gupta School of Management, IIT Kharagpur 12

Page 13: Classification and Clustering Analysis using Weka

Listing 3. Cluster Output with 5 clusters

Vinod Gupta School of Management, IIT Kharagpur 13

Page 14: Classification and Clustering Analysis using Weka

Listing 4. Cluster Output with 10 Clusters

Clusters

One thing that is clear from the clusters is that behavior of Male are clustered in only 2-3

groups while females behavior are heavily distributed among 7 clusters, so preparing an

offering for a specific

Description of Clusters-

Cluster 0- This group consists of unmarried, mid-income earning females in their early 40’s

who live in rural areas. They have on an average two children, no car and personal equity plan

but they do have savings and current account.

Cluster 1- This group consists of married, high-income earning females in their late 40’s who

live in rural areas. They have on an average two children,no car and personal equity plan but

they do have savings and current account.

Cluster 2- This group consists of married, low-income earning females in their early 40’s who

live in inner city. They have on an average one child, no car and savings account but they do

have current account and personal equity plan.

Vinod Gupta School of Management, IIT Kharagpur 14

Page 15: Classification and Clustering Analysis using Weka

Cluster 3- This group consists of married, low-income earning females in their early 30’s who

live in town. They have on an average one or two children, no car, savings account and

personal equity plan but they do have current account.

Cluster 4- This group consists of married, mid-income earning males in their late 30’s who

live in inner city. They have on an average one or no child, no savings account but they do

have personal equity plan, savings & current account.

Cluster 5- This group consists of unmarried, high-income earning males in their early 40’s

who live in town. They have on an average one or no child, they have car, personal equity plan,

savings & current account.

Cluster 6- This group consists of married, mid-income earning females in their early 40’s

who live in inner city. They mostly don’t have ant child, they do not have any savings account

and personal equity plan but they do have current account.

Cluster 7- This group consists of unmarried, high-income earning females in their mid 40’s

who live in inner city. They have on an average one or two child, no car and personal equity

plan but they do have savings & current account.

Cluster 8- This group consists of unmarried, high-income earning females in their mid 40’s

who live in town. They have on an average one or no child, no personal equity plan but they do

have car, savings & current account.

Cluster 9- This group consists of married, mid-income earning males in their early 40’s who

live in inner city. They have on an average one or two children, no car, personal equity plan

and current account but they do have savings account.

Vinod Gupta School of Management, IIT Kharagpur 15

Page 16: Classification and Clustering Analysis using Weka

One other interesting way to examine the data in these clusters is to inspect it visually. To do

this, you should right-click on theResult List section of the Cluster tab . One of the options

from this pop-up menu is Visualize Cluster Assignments. A window will pop up that lets you

play with the results and see them visually. For this example, change the X axis to be income

(Num), the Y axis to children (Num), and the Color to Cluster (Nom). This will show us in a

chart how the clusters are grouped in terms of income and no’ of children. Also, turn up the

"Jitter" to about three-fourths of the way maxed out, which will artificially scatter the plot

points to allow us to see them more easily.

Figure 6. Cluster Visual Inspection

Vinod Gupta School of Management, IIT Kharagpur 16

Page 17: Classification and Clustering Analysis using Weka

Other Applications of Weka

•DISCRETIZATION

•REGRESSION

•NEAREST NEIGHBOR

Referenceshttps://www.ibm.com/developerworks/opensource/library/os-weka2/

http://maya.cs.depaul.edu/classes/ect584/weka/preprocess.html

http://www.cs.waikato.ac.nz/~ml/weka/

Vinod Gupta School of Management, IIT Kharagpur 17