R Examples

To learn more about R, check out my open-access textbook Deep R Programming.

How to Install

To install the package from CRAN, call:

install.packages("lumbermark")

Basic Use

Note

This section is a work in progress. In the meantime, take a look at the documentation of the lumbermark function.

wut/z2 is an example dataset with five clusters of rather non-homogeneous densities. Lumbermark separates them correctly with no need for further parameter tuning:

Z2 <- as.matrix(read.table("z2.data.gz"))
library("lumbermark")
lumbermark_labels <- lumbermark(Z2, 5)
plot(Z2, asp=1, ann=FALSE, col=lumbermark_labels)
../_images/r_z2_dataset-1.png

Figure 4 The z2 dataset

Outlier Detection in the Case of Clusters of Heterogeneous Densities

The recently-developed Deadwood outlier detection algorithm works quite well in the case of clusters of similar densities. However, we can combine it with Lumbermark to detect outliers in each detected cluster separately.

par(mfrow=c(1, 2))

library("deadwood")

is_outlier_homo   <- deadwood(Z2)
plot(Z2, asp=1, xlab=NA, ylab=NA,
    col=c("#00000055","#ff333333")[is_outlier_homo+1], main="Deadwood")

is_outlier_hetero <- deadwood(lumbermark_labels)
plot(Z2, asp=1, xlab=NA, ylab=NA,
    col=c("#00000055","#ff333333")[is_outlier_hetero+1], main="Deadwood+Lumbermark")
../_images/r_z2_deadwood-1.png

Figure 5 Outlier detection of the z2 dataset