# How to plot Optics Clustering result in Matlab (reachability plot)

I modified the following script for Optics clustering ( http://chemometria.us.edu.pl/download/OPTICS.M ) in order to work with DTW distance instead than Euclidean's.

I obtained the Order vector (order), Reachability distances (RD) vector and Core distances (CD) vector.

As I read from Wikipedia (http://en.wikipedia.org/wiki/OPTICS_algorithm#Extracting_the_clusters)

Using a reachability-plot (a special kind of dendrogram), the hierarchical structure of the clusters can be obtained easily. It is a 2D plot, with the ordering of the points as processed by OPTICS on the x-axis and the reachability distance on the y-axis. Since points belonging to a cluster have a low reachability distance to their nearest neighbor, the clusters show up as valleys in the reachability plot. The deeper the valley, the denser the cluster. The image above illustrates this concept. In its upper left area, a synthetic example data set is shown. The upper right part visualizes the spanning tree produced by OPTICS, and the lower part shows the reachability plot as computed by OPTICS. Colors in this plot are labels, and not computed by the algorithm; but it is well visible how the valleys in the plot correspond to the clusters in above data set. The yellow points in this image are considered noise, and no valley is found in their reachability plot. They will usually not be assigned to clusters except the omnipresent "all data" cluster in a hierarchical result.

I can represent the results on a scatter plot using the Order as X-axis, and RD as Y-axis.

How can I obtain a hierarchical dendrogram from my data? How can I obtain a spanning tree from my data (and display it)?

• Consider using ELKI, which was used to make the figure on Wikipedia. It supports DTW out of the box. The Matlab implementations of DBSCAN and OPTICS are said to be of low quality. – Anony-Mousse May 19 '14 at 8:19
• Have a look on this PDF on page 16. osl.iu.edu/~chemuell/projects/presentations/optics-v1.pdf They explain very simply how to construct an hierarchical clustering from a reachability plot. – buras Dec 4 '14 at 9:14
• There is an example implementation of OPTICS clustering algorithm on this webpage: mi.eng.cam.ac.uk/~agk34/software.html – user69433 Feb 20 '15 at 16:18

## protected by Community♦Feb 20 '15 at 16:48

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?