concept OPTICS in category R

This is an excerpt from Manning's book Machine Learning with R, the tidyverse, and mlr.
In this section, I’ll show you how the OPTICS algorithm learns regions of high density in a dataset, how it’s similar to DBSCAN, and how it differs. Technically speaking, OPTICS isn’t actually a clustering algorithm. Instead, it creates an ordering of the cases in the data in such a way that we can extract clusters from it. That sounds a little abstract, so let’s work through how OPTICS works.
Figure 18.3. Defining the core distance and reachability distance. In OPTICS, epsilon (ϵ) is the maximum search distance. The core distance (ϵ′) is the minimum search distance needed to include minPts cases (including the case in question). The reachability distance for a case is the larger of the core distance and the distance between the case in question, and another case inside its epsilon (maximum search distance).
![]()
Because the reachability distance is the distance between one core point and another core point within its epsilon, OPTICS needs to know which cases are core points. So the algorithm starts by visiting every case in the data and determining whether its core distance is less than epsilon. This is illustrated in figure 18.4. If a case’s core distance is less than or equal to epsilon, the case is a core point. If a case’s core distance is greater than epsilon (we need to expand out further than epsilon to find minPts cases), the case is not a core point. Examples of both are shown in figure 18.4.
Figure 18.4. Defining core points in OPTICS. Cases for which the core distance (ϵ′) is less than or equal to the maximum search distance (ϵ) are considered core points. Cases for which the core distance is greater than the maximum search distance are not considered core points.
![]()
Now that you understand the concepts of core distance and reachability distance, let’s see how the OPTICS algorithm works. The first step is to visit each case in the data and mark it as a core point or not. The rest of the algorithm is illustrated in figure 18.5, so let’s assume this has been done. OPTICS selects a case and calculates its core distance and its reachability distance to all cases inside its epsilon (the maximum search distance).
OPTICS is able to learn a hierarchical clustering structure and doesn’t require the tuning of epsilon. OPTICS is able to find clusters of differing density.
Use dbscan() to cluster our unscaled data: swissDbsUnscaled <- dbscan::dbscan(swissTib, eps = 1.2, minPts = 9) swissDbsUnscaled # The clusters are not the same as those learned for the scaled data. # This is because DBSCAN and OPTICS are sensitive to scale differences.swissDbsUnscaled <- dbscan::dbscan(swissTib, eps = 1.2, minPts = 9) swissDbsUnscaled # The clusters are not the same as those learned for the scaled data. # This is because DBSCAN and OPTICS are sensitive to scale differences.