O'Reilly logo

R: Recipes for Analysis, Visualization and Machine Learning by Chiu Yu-Wei, Atmajitsinh Gohil, Shanthi Viswanathan, Viswa Viswanathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Clustering data with the density-based method

As an alternative to distance measurement, you can use a density-based measurement to cluster data. This method finds an area with a higher density than the remaining area. One of the most famous methods is DBSCAN. In the following recipe, we will demonstrate how to use DBSCAN to perform density-based clustering.

Getting ready

In this recipe, we will use simulated data generated from the mlbench package.

How to do it...

Perform the following steps to perform density-based clustering:

  1. First, install and load the fpc and mlbench packages:
    > install.packages("mlbench")
    > library(mlbench)
    > install.packages("fpc")
    > library(fpc)
    
  2. You can then use the mlbench library to draw a Cassini problem graph:
    > set.seed(2) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required