GdmFull {dml} | R Documentation |
Global Distance Metric Learning
Description
Performs Global Distance Metric Learning (GDM) on the given data, learning a full matrix.
Usage
GdmFull(data, simi, dism, maxiter = 100)
Arguments
data |
|
simi |
|
dism |
|
maxiter |
numeric, the number of iteration. |
Details
Put GdmFull function details here.
Value
list of the GdmDiag results:
newData |
GdmDiag transformed data |
fullA |
suggested Mahalanobis matrix |
dmlA |
matrix to transform data, square root of diagonalA |
converged |
whether the iteration-projection optimization is converged or not |
For every two original data points (x1, x2) in newData (y1, y2):
(x2 - x1)' * A * (x2 - x1) = || (x2 - x1) * B ||^2 = || y2 - y1 ||^2
Note
Be sure to check whether the dimension of original data and constrains' format are valid for the function.
Author(s)
Gao Tao <http://www.gaotao.name>
References
Steven C.H. Hoi, W. Liu, M.R. Lyu and W.Y. Ma (2003). Distance metric learning, with application to clustering with side-information.
Examples
## Not run:
set.seed(123)
library(MASS)
library(scatterplot3d)
# generate simulated Gaussian data
k = 100
m <- matrix(c(1, 0.5, 1, 0.5, 2, -1, 1, -1, 3), nrow =3, byrow = T)
x1 <- mvrnorm(k, mu = c(1, 1, 1), Sigma = m)
x2 <- mvrnorm(k, mu = c(-1, 0, 0), Sigma = m)
data <- rbind(x1, x2)
# define similar constrains
simi <- rbind(t(combn(1:k, 2)), t(combn((k+1):(2*k), 2)))
temp <- as.data.frame(t(simi))
tol <- as.data.frame(combn(1:(2*k), 2))
# define disimilar constrains
dism <- t(as.matrix(tol[!tol %in% simi]))
# transform data using GdmFull
result <- GdmFull(data, simi, dism)
newData <- result$newData
# plot original data
color <- gl(2, k, labels = c("red", "blue"))
par(mfrow = c(2, 1), mar = rep(0, 4) + 0.1)
scatterplot3d(data, color = color, cex.symbols = 0.6,
xlim = range(data[, 1], newData[, 1]),
ylim = range(data[, 2], newData[, 2]),
zlim = range(data[, 3], newData[, 3]),
main = "Original Data")
# plot GdmFull transformed data
scatterplot3d(newData, color = color, cex.symbols = 0.6,
xlim = range(data[, 1], newData[, 1]),
ylim = range(data[, 2], newData[, 2]),
zlim = range(data[, 3], newData[, 3]),
main = "Transformed Data")
## End(Not run)