concept minPts in category R

This is an excerpt from Manning's book Machine Learning with R, the tidyverse, and mlr.
minPts
In this section, I’ll show you how to select sensible ranges of epsilon and minPts for DBSCAN, and how we can tune them manually to find the best-performing combination. Choosing the value of the epsilon hyperparameter is, perhaps, not obvious. How far away from each case should we search? Luckily, there is a heuristic method we can use to at least get in the right ballpark. This consists of calculating the distance from each point to its kth-nearest neighbor and then ordering the points in a plot based on this distance. In data with regions of high and low density, this tends to produce a plot containing a “knee” or “elbow” (depending on your preference). The optimal value of epsilon is in or near that knee/elbow. Because a core point in DBSCAN has minPts cases inside its epsilon, choosing a value of epsilon at the knee of this plot means choosing a search distance that will result in cases in high-density regions being considered core points. We can create this plot using the kNNdistplot() function from the dbscan package.
Now that we’ve defined our hyperparameter search space, let’s run the DBSCAN algorithm on each distinct combination of epsilon and minPts. To do this, we use the pmap() function from the purrr package to apply the dbscan() function to each row of the dbsParamSpace object.
Listing 18.5. Running DBSCAN on each combination of hyperparameters
swissDbs <- pmap(dbsParamSpace, dbscan, x = swissScaled) swissDbs[[5]] DBSCAN clustering for 200 objects. Parameters: eps = 1.6, minPts = 1 The clustering contains 10 cluster(s) and 0 noise points. 1 2 3 4 5 6 7 8 9 10 1 189 1 1 1 3 1 1 1 1 Available fields: cluster, eps, minPtsWe supply our scaled dataset as the argument to dbscan()’s argument, x. The output from pmap() is a list where each element is the result of running DBSCAN on that particular combination of epsilon and minPts. To view the output for a particular permutation, we simply subset the list.
The output, when printing the result of a dbscan() call, tells us the number of objects in the data, the values of epsilon and minPts, and the number of identified clusters and noise points. Perhaps the most important information is the number of cases within each cluster. In this example, we can see there are 189 cases in cluster 2, and just a single case in most of the other clusters. This is because this permutation was run with minPts equal to 1, which allows clusters to contain just a single case. This is rarely what we want and will result in a clustering model where no cases are identified as noise.
Figure 18.10. Visualizing the result of our tuning experiment. Each subplot shows the Right and Diagonal variables plotted against each other for a different permutation of epsilon and minPts. Cases are shaded by their cluster membership.
![]()
How are we going to choose the best-performing combination of epsilon and minPts? Well, as we saw in chapter 17, visually checking to make sure the clusters are sensible is important, but we can also calculate internal cluster metrics to help guide our choice.