Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Applied Unsupervised Learning with R
  • Table Of Contents Toc
Applied Unsupervised Learning with R

Applied Unsupervised Learning with R

By : Alok Malik, Bradford Tuckfield
4.8 (10)
close
close
Applied Unsupervised Learning with R

Applied Unsupervised Learning with R

4.8 (10)
By: Alok Malik, Bradford Tuckfield

Overview of this book

Starting with the basics, Applied Unsupervised Learning with R explains clustering methods, distribution analysis, data encoders, and features of R that enable you to understand your data better and get answers to your most pressing business questions. This book begins with the most important and commonly used method for unsupervised learning - clustering - and explains the three main clustering algorithms - k-means, divisive, and agglomerative. Following this, you'll study market basket analysis, kernel density estimation, principal component analysis, and anomaly detection. You'll be introduced to these methods using code written in R, with further instructions on how to work with, edit, and improve R code. To help you gain a practical understanding, the book also features useful tips on applying these methods to real business problems, including market segmentation and fraud detection. By working through interesting activities, you'll explore data encoders and latent variable models. By the end of this book, you will have a better understanding of different anomaly detection methods, such as outlier detection, Mahalanobis distances, and contextual and collective anomaly detection.
Table of Contents (9 chapters)
close
close

Chapter 2: Advanced Clustering Methods


Activity 5: Implementing k-modes Clustering on the Mushroom Dataset

Solution:

  1. Download mushrooms.csv from https://github.com/TrainingByPackt/Applied-Unsupervised-Learning-with-R/blob/master/Lesson02/Activity05/mushrooms.csv.

  2. After downloading, load the mushrooms.csv file in R:

    ms<-read.csv('mushrooms.csv')
  3. Check the dimensions of the dataset:

    dim(ms)

    The output is as follows:

    [1] 8124   23
  4. Check the distribution of all columns:

    summary.data.frame(ms)

    The output is as follows:

    Figure 2.29: Screenshot of the summary of distribution of all columns

    Each column contains all the unique labels and their count.

  5. Store all the columns of the dataset, except for the final label, in a new variable, ms_k:

    ms_k<-ms[,2:23]
  6. Import the klaR library, which has the kmodes function:

    install.packages('klaR')
    library(klaR)
  7. Calculate kmodes clusters and store them in a kmodes_ms variable. Enter the dataset without true labels as the first parameter and enter the number of clusters as...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Applied Unsupervised Learning with R
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon