Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Data Mining Clustering & Classification Reference: Tan et al: Introduction to data mining. Some slides are adopted from Tan et al.

Similar presentations


Presentation on theme: "Introduction to Data Mining Clustering & Classification Reference: Tan et al: Introduction to data mining. Some slides are adopted from Tan et al."— Presentation transcript:

1 Introduction to Data Mining Clustering & Classification Reference: Tan et al: Introduction to data mining. Some slides are adopted from Tan et al

2 Clustering

3 What is Cluster Analysis? Finding groups of objects such that the objects in a group will be similar (or related) to one another and different from (or unrelated to) the objects in other groups Inter-cluster distances are maximized Intra-cluster distances are minimized

4 Applications of Cluster Analysis Understanding –Group related documents for browsing, group genes and proteins that have similar functionality, or group stocks with similar price fluctuations Summarization –Reduce the size of large data sets Clustering precipitation in Australia

5 What is not Cluster Analysis? Supervised classification –Have class label information Simple segmentation –Dividing students into different registration groups alphabetically, by last name Results of a query –Groupings are a result of an external specification Graph partitioning –Some mutual relevance and synergy, but areas are not identical

6 Notion of a Cluster can be Ambiguous How many clusters? Four ClustersTwo Clusters Six Clusters

7 Partitional Clustering Original Points A Partitional Clustering

8 Hierarchical Clustering

9 Clustering Algorithms K-means and its variants Hierarchical clustering Density-based clustering

10 K-means Clustering Partitional clustering approach Each cluster is associated with a centroid (center point) Each point is assigned to the cluster with the closest centroid Number of clusters, K, must be specified The basic algorithm is very simple

11 Distance and Centroid calculation

12 K-means Clustering – Details Initial centroids are often chosen randomly. –Clusters produced vary from one run to another. The centroid is (typically) the mean of the points in the cluster. ‘Closeness’ is measured by Euclidean distance, cosine similarity, correlation, etc. K-means will converge for common similarity measures mentioned above. Most of the convergence happens in the first few iterations. –Often the stopping condition is changed to ‘Until relatively few points change clusters’

13 Example Assume desired number of clusters is k=2. Use the k- means algorithm to cluster the records. 1.Choose records 3 and 6 as initial centroids (may choose others) for C1 and C2 2.Calculate the distances for records to these points So records 1,4,5 join 3, record 2 joins 6 3. Calculate new means New means for C1 is (33.75, 8.75) new means for C2 is (52.5, 25) 4. Recalculate the distance to and reassign them according to the distance. This will assign records 1,4,5 to C1, and 2,3,6 to C2. 5. New means for C1 and C2 are (28.3, 6.7) and (51.7, 21.7) respectively. 6. In the next iteration, all records stay where they were before, stop. recorddistance to 3distance to 6 1 22.4 32 2105 30 425.536.6 520.629.2 60

14 Evaluating K-means Clusters Most common measure is Sum of Squared Error (SSE) –For each point, the error is the distance to the nearest cluster –To get SSE, we square these errors and sum them. –x is a data point in cluster C i and m i is the representative point for cluster C i can show that m i corresponds to the center (mean) of the cluster –Given two clusters, we can choose the one with the smallest error –One easy way to reduce SSE is to increase K, the number of clusters A good clustering with smaller K can have a lower SSE than a poor clustering with higher K

15 Selecting initial points Choosing initial k points is a key step of the basic k- means algorithm. Different initial points will result in different clusters A common approach is to choose randomly, but the resulting clusters are often poor.

16 Classification

17 Classification: Definition Given a collection of records (training set ) –Each record contains a set of attributes, one of the attributes is the class. Find a model for class attribute as a function of the values of other attributes. Goal: previously unseen records should be assigned a class as accurately as possible. –A test set is used to determine the accuracy of the model. Usually, the given data set is divided into training and test sets, with training set used to build the model and test set used to validate it.

18 Illustrating Classification Task

19 Examples of Classification Task Predicting tumor cells as benign or malignant Classifying credit card transactions as legitimate or fraudulent Classifying secondary structures of protein as alpha-helix, beta-sheet, or random coil Categorizing news stories as finance, weather, entertainment, sports, etc

20 School of Information and Communication Technology – Griffith University, Australia

21 Classification Techniques Decision Tree based Methods Rule-based Methods Memory based reasoning Neural Networks Naïve Bayes and Bayesian Belief Networks Support Vector Machines

22 Example of a Decision Tree categorical continuous class Refund MarSt TaxInc YES NO YesNo Married Single, Divorced < 80K> 80K Splitting Attributes Training Data Model: Decision Tree

23 Another Example of Decision Tree categorical continuous class MarSt Refund TaxInc YES NO Yes No Married Single, Divorced < 80K> 80K There could be more than one tree that fits the same data!

24 Decision Tree Classification Task Decision Tree

25 Apply Model to Test Data Refund MarSt TaxInc YES NO YesNo Married Single, Divorced < 80K> 80K Test Data Start from the root of tree.

26 Apply Model to Test Data Refund MarSt TaxInc YES NO YesNo Married Single, Divorced < 80K> 80K Test Data

27 Apply Model to Test Data Refund MarSt TaxInc YES NO YesNo Married Single, Divorced < 80K> 80K Test Data

28 Apply Model to Test Data Refund MarSt TaxInc YES NO YesNo Married Single, Divorced < 80K> 80K Test Data

29 Apply Model to Test Data Refund MarSt TaxInc YES NO YesNo Married Single, Divorced < 80K> 80K Test Data

30 Apply Model to Test Data Refund MarSt TaxInc YES NO YesNo Married Single, Divorced < 80K> 80K Test Data Assign Cheat to “No”

31 Decision Tree Classification Task Decision Tree

32 Decision Tree Induction Many Algorithms: –Hunt’s Algorithm (one of the earliest) –CART –ID3, C4.5 –SLIQ,SPRINT

33 General Structure of Hunt’s Algorithm Let D t be the set of training records associated with node t General Procedure: –If D t contains records that belong the same class y t, then t is a leaf node labeled as y t –If D t is an empty set, then t is a leaf node labeled by the default class, y d –If D t contains records that belong to more than one class, use an attribute test to split the data into smaller subsets. Recursively apply the procedure to each subset. DtDt ?

34 Hunt’s Algorithm Don’t Cheat Refund Don’t Cheat Don’t Cheat YesNo Refund Don’t Cheat YesNo Marital Status Don’t Cheat Single, Divorced Married Taxable Income Don’t Cheat < 80K>= 80K Refund Don’t Cheat YesNo Marital Status Don’t Cheat Single, Divorced Married

35 Tree Induction Greedy strategy. –Split the records based on an attribute test that optimizes certain criterion. Issues –Determine how to split the records How to specify the attribute test condition? How to determine the best split? –Determine when to stop splitting Details omitted (see any data mining text).

36 Evaluating the model


Download ppt "Introduction to Data Mining Clustering & Classification Reference: Tan et al: Introduction to data mining. Some slides are adopted from Tan et al."

Similar presentations


Ads by Google