Transcription of Practical Guide To Cluster Analysis in R
1 1 A. Kassambara 2015 Multivariate Analysis I Alboukadel Kassambara Practical Guide To Cluster Analysis in R Edition 1 Unsupervised Machine Learning 2 Copyright 2017 by Alboukadel Kassambara. All rights by STHDA( ), Alboukadel part of this publication may be reproduced, stored in a retrieval system, or transmitted in any formor by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, without the priorwritten permission of the Publisher. Requests to the Publisher for permission shouldbe addressed to STHDA ( ).Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best e orts inpreparing this book, they make no representations or warranties with respect to the accuracy orcompleteness of the contents of this book and specifically disclaim any implied warranties ofmerchantability or fitness for a particular purpose.
2 No warranty may be created or extended by salesrepresentatives or written sales the Publisher nor the authors, contributors, or editors,assume any liability for any injury and/or damageto persons or property as a matter of products liability,negligence or otherwise, or from any use or operation of anymethods, products, instructions, or ideas contained in the material general information contact Alboukadel Kassambara PrefaceLarge amounts of data are collected every day from satellite images, bio-medical,security, marketing, web search, geo-spatial or other automatic equipment. Miningknowledge from these big data far exceeds human s one of the important data mining methods for discovering knowledgein multidimensional data. The goal of clustering is to identify pattern or groups ofsimilar objects within a data set of the litterature, it is referred as pattern recognition or unsupervised machinelearning - unsupervised because we are not guided by a priori ideas of whichvariables or samples belong in which clusters.
3 Learning because the machinealgorithm learns how to Analysis is popular in many fields, including: Incancer researchfor classifying patients into subgroups according their geneexpression profile. This can be useful for identifying the molecular profile ofpatients with good or bad prognostic, as well as for understanding the disease. Inmarketingformarket segmentationby identifying subgroups of customers withsimilar profiles and who might be receptive to a particular form of advertising. InCity-planningfor identifying groups of houses according to their type, valueand book provides a Practical Guide to unsupervised machine learning or clusteranalysis using R software. Additionally, we developped an R package namedfactoextrato create, easily, a ggplot2-based elegant plots of Cluster Analysis results. Factoextrao cial online documentation: About the authorAlboukadel Kassambara is a PhD in Bioinformatics and Cancer Biology.
4 He works sincemany years on genomic data Analysis and visualization. He created a bioinformaticstool named GenomicScape ( ) which is an easy-to-use web toolfor gene expression data Analysis and developed also a website called STHDA (Statistical Tools for High-throughput DataAnalysis, ), which contains many tutorials on data analysisand visualization using R software and is the author of the R packagessurvminer(for analyzing and drawing survivalcurves),ggcorrplot(for drawing correlation matrix using ggplot2) andfactoextra(to easily extract and visualize the results of multivariate Analysis such PCA, CA,MCA and clustering). You can learn more about these packages at: , he published two books on data to Create Beautiful Graphics in R (at: ). Guide to 3D Plots in R (at: ). Preface .. About the author .. Key features of this book .. How this book is organized?
5 Book website .. Executing the R codes from the PDF ..16I Basics171 Introduction to Install R and RStudio .. Installing and loading R packages .. Getting help with functions in R .. Importing your data into R .. Demo data sets .. Close your R/RStudio session ..222 Data Preparation and R Data preparation .. Required R Packages ..243 Clustering Distance Methods for measuring distances .. What type of distance measures should we choose? .. Data standardization .. Distance matrix computation .. Visualizing distance matrices .. Summary ..3356 CONTENTSII Partitioning Clustering344 K-Means K-means basic ideas .. K-means algorithm .. Computing k-means clustering in R .. K-means clustering advantages and disadvantages .. Alternative to k-means clustering .. Summary ..475 PAM concept.
6 PAM algorithm .. Computing PAM in R .. Summary ..566 CLARA - Clustering Large CLARA concept .. CLARA Algorithm .. Computing CLARA in R .. Summary ..63 III Hierarchical Clustering647 Agglomerative Algorithm .. Steps to agglomerative hierarchical clustering .. Verify the Cluster tree .. Cut the dendrogram into di erent groups .. Cluster R package .. Application of hierarchical clustering to gene expression data Summary ..788 Comparing Data preparation .. Comparing dendrograms ..809 Visualizing Visualizing dendrograms .. Case of dendrogram with large data sets .. Manipulating dendrograms using dendextend .. Summary ..9610 Heatmap: Static and R Packages/functions for drawing heatmaps .. Data preparation .. R base heatmap: heatmap() .. Enhanced heat maps: () .. Pretty heat maps: pheatmap().
7 Interactive heat maps: d3heatmap() .. Enhancing heatmaps using dendextend .. Complex heatmap .. Application to gene expression matrix ..116IV Cluster Validation11711 Assessing Clustering Required R packages .. Data preparation .. Visual inspection of the data .. Why assessing clustering tendency? .. Methods for assessing clustering tendency .. Summary ..12712 Determining the Optimal Number of Elbow method .. Average silhouette method .. Gap statistic method .. Computing the number of clusters using R .. Summary ..13713 Cluster Validation Internal measures for Cluster validation .. External measures for clustering validation .. Computing Cluster validation statistics in R .. Summary ..15014 Choosing the Best Clustering Measures for comparing clustering algorithms .. Compare clustering algorithms in R .. Summary.
8 15515 Computing P-value for Hierarchical Algorithm .. Required packages .. Data preparation .. Compute p-value for hierarchical clustering ..158V Advanced Clustering16116 Hierarchical K-Means Algorithm .. R code .. Summary ..16617 Fuzzy Required R packages .. Computing fuzzy clustering .. Summary ..17018 Model-Based Concept of model-based clustering .. Estimating model parameters .. Choosing the best model .. Computing model-based clustering in R .. Visualizing model-based clustering ..17519 DBSCAN: Density-Based Why DBSCAN? .. Algorithm .. Advantages .. Parameter estimation .. Computing DBSCAN .. Method for determining the optimal eps value .. Cluster predictions with DBSCAN algorithm ..18520 References and Further KEY FEATURES OF THIS Key features of this bookAlthough there are several good books on unsupervised machine learning/clusteringand related topics, we felt that many of them are either too high-level, theoreticalor too advanced.
9 Our goal was to write a Practical Guide to Cluster Analysis , elegantvisualization and main parts of the book include: distance measures, partitioning clustering, hierarchical clustering, Cluster validation methods, as well as, advanced clustering methodssuch as fuzzy clustering, density-based clusteringand model-based book presents the basic principles of these tasks and provide many examples inR. This book o ers solid guidance in data mining for students and features: Covers clustering algorithm and implementation Key mathematical concepts are presented Short, self-contained chapters with Practical examples. This means that, youdon t need to read the di erent chapters in the end of each chapter, we present R lab sections in which we systematicallywork through applications of the various methods discussed in that How this book is organized?
10 This book contains 5 parts. Part I (Chapter 1 - 3) provides a quick introduction toR (chapter 1) and presents required R packages and data format (Chapter 2) forclustering Analysis and classification of objects, into clusters, requires some methods for measuring thedistance or the (dis)similarity between the objects. Chapter 3 covers the commondistance measures used for assessing similarity between II starts with partitioning clustering methods, which include: K-means clustering (Chapter 4), K-Medoids or PAM (partitioning around medoids) algorithm (Chapter 5) and CLARA algorithms (Chapter 6).Partitioning clustering approaches subdivide the data sets into a set of k groups, wherek is the number of groups pre-specified by the HOW THIS BOOK IS ORGANIZED?11 AlabamaAlaskaArizonaArkansasCaliforniaCo loradoConnecticutDelawareFloridaGeorgiaH awaiiIdahoIllinoisIndianaIowaKansasKentu ckyLouisianaMaineMarylandMassachusettsMi chiganMinnesotaMississippiMissouriMontan aNebraskaNevadaNew HampshireNew JerseyNew MexicoNew YorkNorth CarolinaNorth DakotaOhioOklahomaOregonPennsylvaniaRhod e IslandSouth CarolinaSouth DakotaTennesseeTexasUtahVermontVirginiaW ashingtonWest VirginiaWisconsinWyoming-1012-202 Dim1 (62%)Dim2 ( )clusteraaaa1234 Partitioning Clustering PlotIn Part III, we consider agglomerative hierarchical clustering method, which is analternative approach to partitionning clustering for identifying groups in a data does not require to pre-specify the number of clusters to be generated.