In this document, we reproduce a result as seen in Lawrence (2012). The result was about recovering the travel trajectory of a robot from the strength measurement of 30 Wifi signals.
# Load data
rm(list = ls())
library(magrittr)
library(plotly)
fpath <- system.file("robot_wireless", "wireless_complete.csv", package = "maniTools")
wireless_full <- read.csv(fpath, header = FALSE)
ground_truth <- wireless_full[, 1:3]
names(ground_truth) <- c("x", "y", "time")fpath <- system.file("robot_wireless", "wireless.csv", package = "maniTools")
wireless <- read.csv(fpath, header = FALSE) %>% as.matrix()
dim(wireless) # 215 datapoints of 30 wifi signal strength.## [1] 215 30
# Perform dimensionality reduction
proj_data <- RDRToolbox::Isomap(wireless, dim = 2, k = 7)[[1]] %>% as.data.frame()## Computing distance matrix ... done
## Building graph with shortest paths (using 7 nearest neighbours) ... done
## Computing low dimensional embedding ... done
## number of samples: 215
## reduction from 30 to 2 dimensions
## number of connected components in graph: 1
names(proj_data) <- c('x', 'y')# Plotting
p1 <- plot_ly(ground_truth[c('x', 'y')], x = x, y = y, name = "Truth")
p2 <- plot_ly(data = proj_data, x = x, y = y, mode = 'markers+lines', name = "Isomap")
subplot(p1, p2) %>% layout(title = "Isomap")In the above, we recovered the travel trajectory of the robot from the Wifi signals. Note that the scale of the projected data are off because the data we use had been preprocessed and standardised before we loaded them here.
library(maniTools)
# Laplacian Eigenmaps
LE_proj_data <- Laplacian_Eigenmaps(wireless, k = 7, d = 2)[[1]] %>% as.data.frame()
names(LE_proj_data) <- c('x', 'y')
# Locally Linear Embedding
LLE_proj_data <- LLE2(wireless, dim = 2, k = 7) %>% as.data.frame()
names(LLE_proj_data) <- c('x', 'y')
p3 <- plot_ly(data = LE_proj_data, x = x, y = y, mode = 'markers+lines', name = "Laplacian Eigenmaps")
p4 <- plot_ly(data = LLE_proj_data, x = x, y = y, mode = 'markers+lines', name = "Locally Linear Embedding")
subplot(p3, p4)