Data Mining Techniques using WEKA (Ankit Pandey-10BM60012)


Published on

This term paper contains a brief introduction of a powerful data mining tool WEKA along with a hands-on guide to two data mining techniques namely Clustering (k-means) and Linear Regression using WEKA.

Published in: Business, Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Data Mining Techniques using WEKA (Ankit Pandey-10BM60012)

  1. 1. Data Mining Techniques using WEKA IT for Business Intelligence Ankit Pandey (10BM60012)This term paper contains a brief introduction of a powerful data mining tool WEKA along with a hands-on guide to two data mining techniques namely Clustering (k-means) and Linear Regression usingWEKA.
  2. 2. IT for Business IntelligenceData Mining Techniques using WEKAIntroduction to WEKAWEKA (Waikato Environment for Knowledge Analysis) is a collection of state-of-the-artmachine learning algorithms and data preprocessing tools written in Java, developed at theUniversity of Waikato, New Zealand. It is free software that runs on almost any platform andis available under the GNU General Public License. It has a wide range of applications invarious data mining techniques. It provides extensive support for the entire process ofexperimental data mining, including preparing the input data, evaluating learning schemesstatistically, and visualizing the input data and the result of learning. The WEKA workbenchincludes 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 twointerfaces –  Command Line Interface (CLI)  Graphical User Interface (GUI)The WEKA GUI Chooser appears like this – Fig.1The 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? Ankit Pandey (10BM60012), MBA 2nd Year VGSoM IIT Kharagpur 2
  3. 3. IT for Business Intelligence  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:  Clustering (Simple K Means)  Linear regressionClustering using WEKAClusteringClustering is a class of techniques used to classify objects or cases into relatively homogenousgroups called clusters. Objects in each cluster tend to be similar to each other and dissimilarto objects in the other clusters. In clustering, there is no a-priori information about the groupor cluster membership for any of the objects.There are two major types of clustering techniques viz.  Hierarchical Clustering  Non-Hierarchical Clustering (aka k-means Clustering)HIERARCHICAL CLUSTERING - Some measure of distance (usually Euclidean or squared Euclidean)is used to identify distances between all pairs of objects to be clustered. We begin with allobjects in separate clusters. Two closest objects are joined to form a cluster. This processcontinues, until points join existing clusters (because they are closest to an existing cluster),and clusters join other clusters, based on the shortest distance criterion.NON-HIERARCHICAL (K-MEANS ) CL USTERING - We need to rationally specify the number ofclusters we want the objects to be clustered into. In this term paper, i will illustrate theprocess of k-means clustering through WEKA.Business applications of Clustering  Segmentation of the market  Understanding buyer behavior  Identifying new product opportunities  Selecting test markets and Reducing data Ankit Pandey (10BM60012), MBA 2nd Year VGSoM IIT Kharagpur 3
  4. 4. IT for Business IntelligenceK-means clustering in WEKAExample Proble m: A major Indian FMCG company wants to map the profile of its targetmarket in terms of lifestyle, attitudes and perceptions. The companys managers prepare, withthe help of their marketing research team, a set o f 15 statements, which they feel measure manyof the variables of interest. These 15 statements are given below. The respondent had to agreeor disagree (1 = Strongly Agree, 2 = Agree, 3 = Neither Agree nor Disagree, 4 = Disagree, 5= Strongly Disagree) with each statement. 1. I prefer to use e- mail rather than write a letter. 2. I feel that quality products are always priced high. 3. I think twice before I buy anything. 4. Television is a major source of entertainment. 5. A car is a necessity rather than a luxury. 6. I prefer fast food and ready to use products. 7. People are more health conscious today. 8. Entry of foreign companies has increased the efficiency of Indian companies. 9. Women are active participants in purchase decisions. 10. I believe politicians can play a positive role. 11. I enjoy watching movies. 12. If I get a chance, I would like to settle abroad. 13. I always buy branded products. 14. I frequently go out on weekends. 15. I prefer to pay by credit card rather than in cash.The company wants to cluster the market based on the above attributes to facilitate itself ineffectively catering to most feasible and lucrative segment. I will describe how WEKA can beused to do this.For the purpose of simplification we renamed the above 15 statements as variables in csv fileclustering data i.e. “var01” through “var15”. This data file contains 1436 instances(responses). As an input WEKA accepts few file formats including arff and csv. In this case weare using a csv file as an input. Ankit Pandey (10BM60012), MBA 2nd Year VGSoM IIT Kharagpur 4
  5. 5. IT for Business IntelligenceSteps to be followed: 1. Select Explorer in the Weka GUI Chooser window (displayed previously). 2. The following window will appear – Fig.2 3. Select “Open File” and load the csv file clustering data. After loading the file, the interface will be like this – Fig.3 Ankit Pandey (10BM60012), MBA 2nd Year VGSoM IIT Kharagpur 5
  6. 6. IT for Business Intelligence 4. We can click on “Visualize All” to view the distribution of all variables in the sample population as follows: Fig.4 The preprocessing tasks in WEKA obviate the need to convert the data set into the standard spreadsheet format and convert categorical attributes to binary. The WEKA SimpleKMeans algorithm uses Euclidean distance measure to compute distances between instances and clusters. 5. For performing clustering operation, select the tab “Cluster” in the explorer window. Fig.5[All the figures from Fig. 4 onwards can be viewed more clearly in a separate window by clicking over them] Ankit Pandey (10BM60012), MBA 2nd Year VGSoM IIT Kharagpur 6
  7. 7. IT for Business Intelligence 6. In the Clusterer panel, click on “Choose” and select “SimpleKMeans”. 7. Then click the text box beside the Choose button (a pop-up window will appear). Set the numClusters value to 4 and click ok. Fig.6 8. Make sure that the Use training set is selected in the Cluster mode panel and then click Start button to begin clustering process. Fig.7Ankit Pandey (10BM60012), MBA 2nd Year VGSoM IIT Kharagpur 7
  8. 8. IT for Business Intelligence 9. In the Result list panel, right click the result and select View in a separate window. Following result will be displayed: Fig.8Interpretation of clustering resultsBased on the values of cluster centroids as shown in the above figure, we can state thecharacteristics of each of the clusters. As an example we will describe the characteristics ofcluster 2 having 264 instances.Cluster 2 characteristics:  Prefer to use e-mail rather than letter and credit cards over cash  Somewhat believe that quality products are priced high  Dont think much before buying, TV not a major source of entertainment  Car is considered more of a luxury, somewhat prefer fast foods  Health conscious, women are active decision makers  Friendly towards products of foreign companies  Enjoy movies, prefer banded products and weekend tripsSimilarly the salient features of each of the clusters can be obtained from the results andwould subsequently help the FMCG firm to take the decision regarding which segment(cluster) it should primarily target. Ankit Pandey (10BM60012), MBA 2nd Year VGSoM IIT Kharagpur 8
  9. 9. IT for Business IntelligenceVisualization of Clustering ResultsA more intuitive way to go through the results is to visualize them in the graphical form. To doso:  Right click the result in the Result list panel  Select Visualize cluster assignments  By setting X-axis variable as Cluster, Y-axis variable as Instance_number and Color as var 11, we get the following output: Fig.9From the above graph we can interpret that people in cluster 0 like watching movies a lotwhile people in cluster 3 don’t like watching movies. Cluster 1 and cluster 2 have mixedresponses which are skewed towards watching movies.Similarly we can change the variables in X-axis, Y-axis and color to visualize other aspects ofresult. Note that WEKA has generated an extra variable named “Cluster” (not present inoriginal data) which signifies the cluster membership of various instances.We can save the output as an arff file by clicking on the save button in Fig. 9.The output file contains an additional attribute cluster for each instance.Thus besides the value of fifteen attributes for any instance, the output also specifies thecluster membership for that instance. Ankit Pandey (10BM60012), MBA 2nd Year VGSoM IIT Kharagpur 9
  10. 10. IT for Business IntelligenceA part of the saved output arff file: @relation Clustering Data_clustered @attribute Instance_number numeric @attribute var01 numeric @attribute var02 numeric @attribute var03 numeric @attribute var04 numeric @attribute var05 numeric @attribute var06 numeric @attribute var07 numeric @attribute var08 numeric @attribute var09 numeric @attribute var10 numeric @attribute var11 numeric @attribute var12 numeric @attribute var13 numeric @attribute var14 numeric @attribute var15 numeric @attribute Cluster {cluster0, cluster1, cluster2, cluster3} @data 0,1,3,1,2,3,1,3,2,3,2,2,1,1,1,1,cluster0 1,2,3,2,3,2,2,3,2,4,1,5,2,2,2,2,cluster3 2,3,2,3,2,3,1,3,3,2,2,2,3,2,2,3,cluster0 3,3,2,2,2,2,2,3,2,1,2,1,2,1,1,1,cluster0 4,2,2,2,2,2,1,3,3,2,2,1,1,3,3,2,cluster0 5,2,2,3,3,1,2,2,2,3,2,1,2,3,3,3,cluster0 6,1,1,2,2,2,1,2,2,2,1,2,3,3,3,1,cluster0 7,2,1,1,2,1,2,1,1,1,1,3,3,1,1,2,cluster0 8,2,1,1,3,2,2,2,1,2,1,2,2,2,2,3,cluster0 9,1,2,2,3,2,1,1,1,3,2,1,1,2,2,1,cluster0 10,2,3,3,2,1,2,1,1,2,2,2,1,1,1,2,cluster0 11,3,2,2,2,3,2,1,1,1,3,2,2,2,2,3,cluster0 12,2,3,2,2,3,3,2,2,2,3,2,3,1,1,2,cluster0 ……..We can also use other clustering methods to group the data into clusters. WEKA is particularlyuseful in the clustering process when the size of data is huge. It can generate clusters prettyquickly even with huge data. With numerous applications of clustering in business, WEKA canbe very useful in the clustering of data in real business scenarios. Ankit Pandey (10BM60012), MBA 2nd Year VGSoM IIT Kharagpur 10
  11. 11. IT for Business IntelligenceLinear Regression using WEKARegressionRegression analysis helps us to determine the nature and stre ngth of relationship betweentwo variables or between one dependent variable and number of independent variables. Inregression analysis, an estimating equation is developed which is a mathematical formula thatrelates the known (independent) variables to the unknown (dependent) variable. After thiscorrelation analysis can be applied to determine the degree to which variables are related.Broadly, regression can be classified into two types:  Simple linear regression (one dependent variable and one independent variable)  Multiple regression (one dependent variable and many independent variables)I will illustrate the process of Multiple regression in WEKA with an example in this term paper.Business applications of Regression  Pricing decisions  Risk Analysis for investments  Sales/Market forecasts  Trend line analysis  Total quality control  Development of better hiring plansRegression in WEKAExample Problem: Kristal Auto (fictional name) is car manufacturing company that haspresence in all segments ranging from A1 segment hatchbacks to premium saloons and SUVs.It is planning to launch a crossover. In its pursuit to price the new crossover appropriately andcompetitively, Kristal wants to determine what all factors determine the price of a car and up towhich extent each factor influences the price. To do so it collects the data for 2220 different carmodels. It considered 10 features that primarily determine the price of a car. Following arethose 10 features:  Displacement (cc)  Mileage (kmpl)  Boot Space (ltrs) Ankit Pandey (10BM60012), MBA 2nd Year VGSoM IIT Kharagpur 11
  12. 12. IT for Business Intelligence  Length (mm)  Anti- lock Braking System (ABS)  Electronic Stability Program (ESP)  Anti-theft alarm  Airbags  Keyless Entry  Global Positioning System (GPS)Then the company regress these independent variables with the price to develop a regressionmodel which could assist it in its pricing decisions. I will describe the regression process usingWEKA in this term paper.We will use the data in csv file named regression data.Steps to be followed: 1. Select Explorer from the WEKA GUI user window and load the file regression data as described in the clustering example. Following screen will appear after this: Fig.1 0 Ankit Pandey (10BM60012), MBA 2nd Year VGSoM IIT Kharagpur 12
  13. 13. IT for Business Intelligence 2. Click Classifier tab in the explorer window and then click the Choose button in the Classifier panel. Then select LinearRegression from functions. Following screen will appear: Fig.1 1It automatically identifies the dependent variable as Price (as shown below Test Options panel).In case it doesn’t happen we can select the dependent variable. 3. Press the Start button. Following output will be generated: Fig.1 2Output can also be viewed in a separate window (as described earlier in clustering example). Ankit Pandey (10BM60012), MBA 2nd Year VGSoM IIT Kharagpur 13
  14. 14. IT for Business IntelligenceWe can see that the output contains the regression equation which can be used to price thenew crossover. (Note that the equation may not be coherent with real life situation as thedata used is manipulated to effectively demonstrate the technique.)From the regression equation we can see that Boot space and length are negatively correlatedto the price, while displacement, ABS and GPS are positively correlated to the price.We can also visualize the classifier error i.e. those instances which are wrongly predicted byregression equation by right clinking on the result set in the Result list panel and selectingVisualize classifier errors. Fig.1 3The X-axis has Price (actual) and the Y-axis has Predicted Price.Other applications of WEKA in data miningWEKA can be used in various other data mining techniques. Some of them are:  Classification (using decision trees)  Collaborative filtering (Nearest Neighbor)  Association Ankit Pandey (10BM60012), MBA 2nd Year VGSoM IIT Kharagpur 14
  15. 15. IT for Business IntelligenceReferences  Data Mining by Ian H. Witten, Eibe Frank and Mark A. Hall (3rd edition, Morgan Kaufmann publisher)  Ankit Pandey (10BM60012), MBA 2nd Year VGSoM IIT Kharagpur 15