Title: | Q-Kernel-Based and Conditionally Negative Definite Kernel-Based Machine Learning Tools |
---|---|
Description: | Nonlinear machine learning tool for classification, clustering and dimensionality reduction. It integrates 12 q-kernel functions and 15 conditional negative definite kernel functions and includes the q-kernel and conditional negative definite kernel version of density-based spatial clustering of applications with noise, spectral clustering, generalized discriminant analysis, principal component analysis, multidimensional scaling, locally linear embedding, sammon's mapping and t-Distributed stochastic neighbor embedding. |
Authors: | Yusen Zhang [aut, cre] , Daolin Pang [ctb], Jinghao Wang [ctb], Jialin Zhang [ctb] |
Maintainer: | Yusen Zhang <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.19 |
Built: | 2024-10-21 05:47:21 UTC |
Source: | https://github.com/cran/qkerntool |
as.cndkernmatrix
in package qkerntool can be used
to create the cndkernmatrix class to matrix objects representing a
CND kernel matrix. These matrices can then be used with the cndkernmatrix
interfaces which most of the functions in qkerntool support.
## S4 method for signature 'matrix' as.cndkernmatrix(x, center = FALSE)
## S4 method for signature 'matrix' as.cndkernmatrix(x, center = FALSE)
x |
matrix to be assigned the |
center |
center the cndkernel matrix in feature space (default: FALSE) |
Yusen Zhang
[email protected]
## Create the data x <- rbind(matrix(rnorm(10),,2),matrix(rnorm(10,mean=3),,2)) y <- matrix(c(rep(1,5),rep(-1,5))) ### Use as.cndkernmatrix to label the cov. matrix as a CND kernel matrix ### which is eq. to using a linear kernel K <- as.cndkernmatrix(crossprod(t(x))) K
## Create the data x <- rbind(matrix(rnorm(10),,2),matrix(rnorm(10,mean=3),,2)) y <- matrix(c(rep(1,5),rep(-1,5))) ### Use as.cndkernmatrix to label the cov. matrix as a CND kernel matrix ### which is eq. to using a linear kernel K <- as.cndkernmatrix(crossprod(t(x))) K
as.qkernmatrix
in package qkerntool can be used
to create the qkernmatrix class to matrix objects representing a
q kernel matrix. These matrices can then be used with the qkernmatrix
interfaces which most of the functions in qkerntool support.
## S4 method for signature 'matrix' as.qkernmatrix(x, center = FALSE)
## S4 method for signature 'matrix' as.qkernmatrix(x, center = FALSE)
x |
matrix to be assigned the |
center |
center the kernel matrix in feature space (default: FALSE) |
Yusen Zhang
[email protected]
## Create the data x <- rbind(matrix(rnorm(10),,2),matrix(rnorm(10,mean=3),,2)) y <- matrix(c(rep(1,5),rep(-1,5))) ### Use as.qkernmatrix to label the cov. matrix as a qkernel matrix ### which is eq. to using a linear kernel K <- as.qkernmatrix(crossprod(t(x))) K
## Create the data x <- rbind(matrix(rnorm(10),,2),matrix(rnorm(10,mean=3),,2)) y <- matrix(c(rep(1,5),rep(-1,5))) ### Use as.qkernmatrix to label the cov. matrix as a qkernel matrix ### which is eq. to using a linear kernel K <- as.qkernmatrix(crossprod(t(x))) K
The kernel generating functions provided in qkerntool.
The Non Linear Kernel .
The Gaussian kernel .
The Laplacian Kernel .
The Rational Quadratic Kernel .
The Multiquadric Kernel .
The Inverse Multiquadric Kernel .
The Wave Kernel .
The d Kernel .
The Log Kernel .
The Cauchy Kernel .
The Chi-Square Kernel .
The Generalized T-Student Kernel .
rbfbase(sigma=1,q=0.8) nonlbase(alpha = 1,q = 0.8) laplbase(sigma = 1, q = 0.8) ratibase(c = 1, q = 0.8) multbase(c = 1, q = 0.8) invbase(c = 1, q = 0.8) wavbase(theta = 1,q = 0.8) powbase(d = 2, q = 0.8) logbase(d = 2, q = 0.8) caubase(sigma = 1, q = 0.8) chibase(gamma = 1, q = 0.8) studbase(d = 2, q = 0.8)
rbfbase(sigma=1,q=0.8) nonlbase(alpha = 1,q = 0.8) laplbase(sigma = 1, q = 0.8) ratibase(c = 1, q = 0.8) multbase(c = 1, q = 0.8) invbase(c = 1, q = 0.8) wavbase(theta = 1,q = 0.8) powbase(d = 2, q = 0.8) logbase(d = 2, q = 0.8) caubase(sigma = 1, q = 0.8) chibase(gamma = 1, q = 0.8) studbase(d = 2, q = 0.8)
q |
for all the qkernel function. |
sigma |
for the Radial Basis qkernel function "rbfbase" , the Laplacian qkernel function "laplbase" and the Cauchy qkernel function "caubase". |
alpha |
for the Non Linear qkernel function "nonlbase". |
c |
for the Rational Quadratic qkernel function "ratibase" , the Multiquadric qkernel function "multbase" and the Inverse Multiquadric qkernel function "invbase". |
theta |
for the Wave qkernel function "wavbase". |
d |
for the d qkernel function "powbase" , the Log qkernel function "logbase" and the Generalized T-Student qkernel function "studbase". |
gamma |
for the Chi-Square qkernel function "chibase". |
The kernel generating functions are used to initialize a kernel
function
which calculates the kernel function value between two feature vectors in a
Hilbert Space. These functions can be passed as a qkernel
argument on almost all
functions in qkerntool(e.g., qkgda
, qkpca
etc).
Return an S4 object of class qkernel
which extents the
function
class. The resulting function implements the given
kernel calculating the kernel function value between two vectors.
qpar |
a list containing the kernel parameters (hyperparameters) used. |
The kernel parameters can be accessed by the qpar
function.
Yusen Zhang
[email protected]
qkfunc <- rbfbase(sigma=1,q=0.8) qkfunc qpar(qkfunc) ## create two vectors x <- rnorm(10) y <- rnorm(10) ## calculate dot product qkfunc(x,y)
qkfunc <- rbfbase(sigma=1,q=0.8) qkfunc qpar(qkfunc) ## create two vectors x <- rnorm(10) y <- rnorm(10) ## calculate dot product qkfunc(x,y)
Y = BLKDIAG(A,B,...) produces diag(A,B,...)
blkdiag(x)
blkdiag(x)
x |
a list of matrix |
E - Block diagonal concatenation of matrix
Yusen Zhang
[email protected]
The built-in kernel classes in qkerntool
Objects can be created by calls of the form new("nonlkernel")
,
new{"polykernel"}
, new{"rbfkernel"}
,
new{"laplkernel"}
, new{"anokernel"}
,
new{"ratikernel"}
, new{"multkernel"}
,
new{"invkernel"}
, new{"wavkernel"}
,
new{"powkernel"}
, new{"logkernel"}
,
new{"caukernel"}
, new{"chikernel"}
,
new{"studkernel"}
,new{"norkernel"}
or by calling the nonlcnd
,polycnd
, rbfcnd
,
laplcnd
, anocnd
, raticnd
, multcnd
,
invcnd
, wavcnd
, powcnd
, logcnd
,
caucnd
, chicnd
, studcnd
, norcnd
functions etc..
.Data
:Object of class "function"
containing
the kernel function
qpar
:Object of class "list"
containing the
kernel parameters
signature(kernel = "rbfkernel", x ="matrix")
: computes the kernel matrix
Yusen Zhang
[email protected]
cndkfunc <- rbfcnd(gamma = 1) cndkfunc qpar(cndkfunc) ## create two vectors x <- rnorm(10) y <- rnorm(10) cndkfunc(x,y)
cndkfunc <- rbfcnd(gamma = 1) cndkfunc qpar(cndkfunc) ## create two vectors x <- rnorm(10) y <- rnorm(10) cndkfunc(x,y)
cndkernmatrix
calculates the kernel matrix or
.
## S4 method for signature 'cndkernel' cndkernmatrix(cndkernel, x, y = NULL)
## S4 method for signature 'cndkernel' cndkernmatrix(cndkernel, x, y = NULL)
cndkernel |
the cndkernel function to be used to calculate the CND kernel
matrix.
This has to be a function of class |
x |
a data matrix to be used to calculate the kernel matrix. |
y |
second data matrix to calculate the kernel matrix. |
Common functions used during kernel based computations.
The cndkernel
parameter can be set to any function, of class
cndkernel, which computes the kernel function value in feature space between two
vector arguments. qkerntool provides more than 10 CND kernel functions
which can be initialized by using the following
functions:
nonlcnd
Non Linear cndkernel function
polycnd
Polynomial cndkernel function
rbfcnd
Gaussian cndkernel function
laplcnd
Laplacian cndkernel function
anocnd
ANOVA cndkernel function
raticnd
Rational Quadratic cndkernel function
multcnd
Multiquadric cndkernel function
invcnd
Inverse Multiquadric cndkernel function
wavcnd
Wave cndkernel function
powcnd
d cndkernel function
logcnd
Log cndkernel function
caucnd
Cauchy cndkernel function
chicnd
Chi-Square cndkernel function
studcnd
Generalized T-Student cndkernel function
(see example.)
cndkernmatrix
returns a conditionally negative definite matrix with a zero diagonal element.
Yusen Zhang
[email protected]
nonlbase
, rbfbase
,
laplbase
, ratibase
, multbase
, invbase
,
wavbase
, powbase
, logbase
, caubase
,
chibase
, studbase
## use the iris data data(iris) dt <- as.matrix(iris[ ,-5]) ## initialize cndkernel function lapl <- laplcnd(gamma = 1) lapl ## calculate cndkernel matrix cndkernmatrix(lapl, dt)
## use the iris data data(iris) dt <- as.matrix(iris[ ,-5]) ## initialize cndkernel function lapl <- laplcnd(gamma = 1) lapl ## calculate cndkernel matrix cndkernmatrix(lapl, dt)
The kernel generating functions provided in qkerntool.
The Non Linear Kernel .
The Polynomial kernel .
The Gaussian kernel .
The Laplacian Kernel .
The ANOVA Kernel .
The Rational Quadratic Kernel .
The Multiquadric Kernel .
The Inverse Multiquadric Kernel .
The Wave Kernel .
The d Kernel .
The Log Kernel .
The Cauchy Kernel .
The Chi-Square Kernel .
The Generalized T-Student Kernel .
The normal Kernel .
nonlcnd(alpha = 1) polycnd(d = 2, alpha = 1, c = 1) rbfcnd(gamma = 1) laplcnd(gamma = 1) anocnd(d = 2, sigma = 1) raticnd(c = 1) multcnd(c = 1) invcnd(c = 1) wavcnd(theta = 1) powcnd(d = 2) logcnd(d = 2) caucnd(gamma = 1) chicnd( ) studcnd(d = 2) norcnd()
nonlcnd(alpha = 1) polycnd(d = 2, alpha = 1, c = 1) rbfcnd(gamma = 1) laplcnd(gamma = 1) anocnd(d = 2, sigma = 1) raticnd(c = 1) multcnd(c = 1) invcnd(c = 1) wavcnd(theta = 1) powcnd(d = 2) logcnd(d = 2) caucnd(gamma = 1) chicnd( ) studcnd(d = 2) norcnd()
alpha |
for the Non Linear cndkernel function "nonlcnd" and the Polynomial cndkernel function "polycnd". |
gamma |
for the Radial Basis cndkernel function "rbfcnd" and the Laplacian cndkernel function "laplcnd" and the Cauchy cndkernel function "caucnd". |
sigma |
for the ANOVA cndkernel function "anocnd". |
theta |
for the Wave cndkernel function "wavcnd". |
c |
for the Rational Quadratic cndkernel function "raticnd", the Polynomial cndkernel function "polycnd", the Multiquadric cndkernel function "multcnd" and the Inverse Multiquadric cndkernel function "invcnd". |
d |
for the Polynomial cndkernel function "polycnd", the ANOVA cndkernel function "anocnd", the cndkernel function "powcnd", the Log cndkernel function "logcnd" and the Generalized T-Student cndkernel function "studcnd". |
The kernel generating functions are used to initialize a kernel
function which calculates the kernel function value between two feature vectors in a
Hilbert Space. These functions can be passed as a qkernel
argument on almost all
functions in qkerntool.
Return an S4 object of class cndkernel
which extents the
function
class. The resulting function implements the given
kernel calculating the kernel function value between two vectors.
qpar |
a list containing the kernel parameters (hyperparameters) used. |
The kernel parameters can be accessed by the qpar
function.
Yusen Zhang
[email protected]
cndkfunc <- rbfcnd(gamma = 1) cndkfunc qpar(cndkfunc) ## create two vectors x <- rnorm(10) y <- rnorm(10) ## calculate dot product cndkfunc(x,y)
cndkfunc <- rbfcnd(gamma = 1) cndkfunc qpar(cndkfunc) ## create two vectors x <- rnorm(10) y <- rnorm(10) ## calculate dot product cndkfunc(x,y)
Eucdist
Computes the Euclidean(square Euclidean) distance matrix.
x |
(NxD) matrix (N samples, D features) |
y |
(MxD) matrix (M samples, D features) |
sEuclidean |
can be TRUE or FALSE, FALSE to Compute the Euclidean distance matrix. |
E - (MxN) Euclidean (square Euclidean) distances between vectors in x and y
Yusen Zhang
[email protected]
### data(iris) testset <- sample(1:150,20) x <- as.matrix(iris[-testset,-5]) y <- as.matrix(iris[testset,-5]) ## res0 <- Eucdist(x) res1 <- Eucdist(x, x, sEuclidean = FALSE) res2 <- Eucdist(x, y = NULL, sEuclidean = FALSE) res3 <- Eucdist(x, x, sEuclidean = TRUE) res4 <- Eucdist(x, y = NULL) res5 <- Eucdist(x, sEuclidean = FALSE)
### data(iris) testset <- sample(1:150,20) x <- as.matrix(iris[-testset,-5]) y <- as.matrix(iris[testset,-5]) ## res0 <- Eucdist(x) res1 <- Eucdist(x, x, sEuclidean = FALSE) res2 <- Eucdist(x, y = NULL, sEuclidean = FALSE) res3 <- Eucdist(x, x, sEuclidean = TRUE) res4 <- Eucdist(x, y = NULL) res5 <- Eucdist(x, sEuclidean = FALSE)
This dataset consists of features of handwritten numerals (‘0’–‘9’) extracted from a collection of Dutch utility maps. 200 patterns per class (for a total of 2,000 patterns) have been digitized in binary images. This dataset is about 240 pixel averages in 2 x 3 windows
data("mfeat_pix")
data("mfeat_pix")
A data frame with 2000 observations on the following 240 variables.
https://archive.ics.uci.edu/ml/datasets/Multiple+Features
data(mfeat_pix)
data(mfeat_pix)
Similiar to the Density-Based Spatial Clustering of Applications with Noise(or DBSCAN) algorithm, qKernel-DBSCAN is a density-based clustering algorithm that can be applied under both linear and non-linear situations.
## S4 method for signature 'matrix' qkdbscan(x, kernel = "rbfbase", qpar = list(sigma = 0.1, q = 0.9), eps = 0.25, MinPts = 5, hybrid = TRUE, seeds = TRUE, showplot = FALSE, countmode = NULL, na.action = na.omit, ...) ## S4 method for signature 'cndkernmatrix' qkdbscan(x, eps = 0.25, MinPts = 5, seeds = TRUE, showplot = FALSE, countmode = NULL, ...) ## S4 method for signature 'qkernmatrix' qkdbscan(x, eps = 0.25, MinPts = 5, seeds = TRUE, showplot = FALSE, countmode = NULL, ...) ## S4 method for signature 'qkdbscan' predict(object, data, newdata = NULL, predict.max = 1000, ...)
## S4 method for signature 'matrix' qkdbscan(x, kernel = "rbfbase", qpar = list(sigma = 0.1, q = 0.9), eps = 0.25, MinPts = 5, hybrid = TRUE, seeds = TRUE, showplot = FALSE, countmode = NULL, na.action = na.omit, ...) ## S4 method for signature 'cndkernmatrix' qkdbscan(x, eps = 0.25, MinPts = 5, seeds = TRUE, showplot = FALSE, countmode = NULL, ...) ## S4 method for signature 'qkernmatrix' qkdbscan(x, eps = 0.25, MinPts = 5, seeds = TRUE, showplot = FALSE, countmode = NULL, ...) ## S4 method for signature 'qkdbscan' predict(object, data, newdata = NULL, predict.max = 1000, ...)
x |
the data matrix indexed by row, or a kernel matrix of |
kernel |
the kernel function used in training and predicting. This parameter can be set to any function, of class kernel, which computes a kernel function value between two vector arguments. qkerntool provides the most popular kernel functions which can be used by setting the kernel parameter to the following strings:
The kernel parameter can also be set to a user defined function of class kernel by passing the function name as an argument. |
qpar |
the list of hyper-parameters (kernel parameters). This is a list which contains the parameters to be used with the kernel function. Valid parameters for existing kernels are :
Hyper-parameters for user defined kernels can be passed through the qpar parameter as well. |
eps |
reachability distance, see Ester et al. (1996). (default:0.25) |
MinPts |
reachability minimum number of points, see Ester et al.(1996).(default : 5) |
hybrid |
whether the algothrim expects raw data but calculates partial distance matrices, can be TRUE or FALSE |
seeds |
can be TRUE or FALSE, FALSE to not include the |
showplot |
whether to show the plot or not, can be TRUE or FALSE |
na.action |
a function to specify the action to be taken if |
countmode |
NULL or vector of point numbers at which to report progress. |
object |
object of class |
data |
matrix or data.frame. |
newdata |
matrix or data.frame with raw data to predict. |
predict.max |
max. batch size for predictions. |
... |
Further arguments transferred to plot methods. |
The data can be passed to the qkdbscan
function in a matrix
, in addition qkdbscan
also supports input in the form of a kernel matrix of class qkernmatrix
or class cndkernmatrix
.
predict
(qkdbscan-method) gives out a vector of predicted clusters for the points in newdata
.
qkdbscan
gives out an S4 object which is a LIST with components
clust |
integer vector coding cluster membership with noise observations (singletons) coded as 0 |
eps |
parameter eps |
MinPts |
parameter MinPts |
kcall |
the function call |
cndkernf |
the kernel function used |
xmatrix |
the original data matrix |
all the slots of the object can be accessed by accessor functions.
The predict function can be used to embed new data on the new space.
Yusen Zhang
[email protected]
Martin Ester, Hans-Peter Kriegel, Joerg Sander, Xiaowei Xu(1996).
A Density-Based Algorithm for Discovering Clusters in Large Spatial Databases with Noise
Institute for Computer Science, University of Munich.
Proceedings of 2nd International Conference on Knowledge Discovery and Data Mining (KDD-96)
qkernmatrix
, cndkernmatrix
# a simple example using the iris data(iris) test <- sample(1:150,20) x<- as.matrix(iris[-test,-5]) ds <- qkdbscan (x,kernel="laplbase",qpar=list(sigma=3.5,q=0.8),eps=0.15, MinPts=5,hybrid = FALSE) plot(ds,x) emb <- predict(ds, x, as.matrix(iris[test,-5])) points(iris[test,], col= as.integer(1+emb))
# a simple example using the iris data(iris) test <- sample(1:150,20) x<- as.matrix(iris[-test,-5]) ds <- qkdbscan (x,kernel="laplbase",qpar=list(sigma=3.5,q=0.8),eps=0.15, MinPts=5,hybrid = FALSE) plot(ds,x) emb <- predict(ds, x, as.matrix(iris[test,-5])) points(iris[test,], col= as.integer(1+emb))
The qkernel-DBSCAN class.
Objects can be created by calls of the form new("qkdbscan", ...)
.
or by calling the qkdbscan
function.
clust
:Object of class "vector"
containing the
cluster membership of the samples
eps
:Object of class "numeric"
containing the
reachability distance
MinPts
:Object of class "numeric"
containing the
reachability minimum number of points
isseed
:Object of class "logical"
containing the logical vector indicating
whether a point is a seed (not border, not noise)
signature(object = "qkdbscan")
: returns the cluster membership
signature(object = "qkdbscan")
: returns the performed call
signature(object = "qkdbscan")
: returns the used kernel function
signature(object = "qkdbscan")
: returns the reachability distance
signature(object = "qkdbscan")
: returns the reachability minimum number of points
signature(object = "qkdbscan")
: embeds new data
signature(object = "qkdbscan")
: returns the used data matrix
Yusen Zhang
[email protected]
qkernel-class
,
cndkernel-class
# a simple example using the iris data x<- as.matrix(iris[,-5]) ds <- qkdbscan (x,kernel="laplbase",qpar=list(sigma=3.5,q=0.8),eps=0.15, MinPts=5,hybrid = FALSE) # print the results clust(ds) eps(ds) MinPts(ds) cndkernf(ds) xmatrix(ds) kcall(ds)
# a simple example using the iris data x<- as.matrix(iris[,-5]) ds <- qkdbscan (x,kernel="laplbase",qpar=list(sigma=3.5,q=0.8),eps=0.15, MinPts=5,hybrid = FALSE) # print the results clust(ds) eps(ds) MinPts(ds) cndkernf(ds) xmatrix(ds) kcall(ds)
The built-in kernel classes in qkerntool
Objects can be created by calls of the form new("rbfqkernel")
,
new{"nonlqkernel"}
, new{"laplqkernel"}
,
new{"ratiqkernel"}
, new{"multqkernel"}
,
new{"invqkernel"}
, new{"wavqkernel"}
,
new{"powqkernel"}
, new{"logqkernel"}
,
new{"cauqkernel"}
, new{"chiqkernel"}
,
new{"studqkernel"}
or by calling the rbfbase
, nonlbase
, laplbase
, ratibase
,
multbase
, invbase
, wavbase
, powbase
,
logbase
, caubase
, chibase
, studbase
functions etc..
.Data
:Object of class "function"
containing
the kernel function
qpar
:Object of class "list"
containing the
kernel parameters
signature(kernel = "rbfqkernel", x =
"matrix")
: computes the qkernel matrix
Yusen Zhang
[email protected]
qkfunc <- rbfbase(sigma=1,q=0.8) qkfunc qpar(qkfunc) ## create two vectors x <- rnorm(10) y <- rnorm(10) ## calculate dot product qkfunc(x,y)
qkfunc <- rbfbase(sigma=1,q=0.8) qkfunc qpar(qkfunc) ## create two vectors x <- rnorm(10) y <- rnorm(10) ## calculate dot product qkfunc(x,y)
qkernmatrix
calculates the qkernel matrix or
.
## S4 method for signature 'qkernel' qkernmatrix(qkernel, x, y = NULL)
## S4 method for signature 'qkernel' qkernmatrix(qkernel, x, y = NULL)
qkernel |
the kernel function to be used to calculate the qkernel
matrix.
This has to be a function of class |
x |
a data matrix to be used to calculate the kernel matrix |
y |
second data matrix to calculate the kernel matrix |
Common functions used during kernel based computations.
The qkernel
parameter can be set to any function, of class
qkernel, which computes the kernel function value in feature space between two
vector arguments. qkerntool provides more than 10 qkernel functions
which can be initialized by using the following
functions:
nonlbase
Non Linear qkernel function
rbfbase
Gaussian qkernel function
laplbase
Laplacian qkernel function
ratibase
Rational Quadratic qkernel function
multbase
Multiquadric qkernel function
invbase
Inverse Multiquadric qkernel function
wavbase
Wave qkernel function
powbase
d qkernel function
logbase
Log qkernel function
caubase
Cauchy qkernel function
chibase
Chi-Square qkernel function
studbase
Generalized T-Student qkernel function
(see example.)
qkernmatrix
returns a conditionally negative definite matrix with a zero diagonal element.
Yusen Zhang
[email protected]
nonlcnd
, rbfcnd
,polycnd
,laplcnd
,
anocnd
, raticnd
, multcnd
, invcnd
,
wavcnd
, powcnd
, logcnd
, caucnd
,
chicnd
, studcnd
data(iris) dt <- as.matrix(iris[ ,-5]) ## initialize kernel function rbf <- rbfbase(sigma = 1.4, q=0.8) rbf ## calculate qkernel matrix qkernmatrix(rbf, dt)
data(iris) dt <- as.matrix(iris[ ,-5]) ## initialize kernel function rbf <- rbfbase(sigma = 1.4, q=0.8) rbf ## calculate qkernel matrix qkernmatrix(rbf, dt)
The qkernel Generalized Discriminant Analysis is a method that deals with nonlinear discriminant analysis using kernel function operator.
## S4 method for signature 'matrix' qkgda(x, label, kernel = "rbfbase", qpar = list(sigma = 0.1, q = 0.9), features = 0, th = 1e-4, na.action = na.omit, ...) ## S4 method for signature 'cndkernmatrix' qkgda(x, label, features = 0, th = 1e-4, na.action = na.omit, ...) ## S4 method for signature 'qkernmatrix' qkgda(x, label, features = 0, th = 1e-4, ...)
## S4 method for signature 'matrix' qkgda(x, label, kernel = "rbfbase", qpar = list(sigma = 0.1, q = 0.9), features = 0, th = 1e-4, na.action = na.omit, ...) ## S4 method for signature 'cndkernmatrix' qkgda(x, label, features = 0, th = 1e-4, na.action = na.omit, ...) ## S4 method for signature 'qkernmatrix' qkgda(x, label, features = 0, th = 1e-4, ...)
x |
the data matrix indexed by row, or a kernel matrix of |
label |
The original labels of the samples. |
kernel |
the kernel function used in training and predicting. This parameter can be set to any function, of class kernel, which computes a kernel function value between two vector arguments. qkerntool provides the most popular kernel functions which can be used by setting the kernel parameter to the following strings:
The kernel parameter can also be set to a user defined function of class kernel by passing the function name as an argument. |
qpar |
the list of hyper-parameters (kernel parameters). This is a list which contains the parameters to be used with the kernel function. Valid parameters for existing kernels are :
Hyper-parameters for user defined kernels can be passed through the qpar parameter as well. |
features |
Number of features (principal components) to return. (default: 0 , all) |
th |
the value of the eigenvalue under which principal components are ignored (only valid when features = 0). (default : 0.0001) |
na.action |
A function to specify the action to be taken if |
... |
additional parameters |
The qkernel Generalized Discriminant Analysis method provides a mapping of the input vectors into high dimensional feature space, generalizing the classical Linear Discriminant Analysis to non-linear discriminant analysis.
The data can be passed to the qkgda
function in a matrix
, in addition qkgda
also supports input in the form of a
kernel matrix of class qkernmatrix
or class cndkernmatrix
.
An S4 object containing the eigenvectors and their normalized projections, along with the corresponding eigenvalues and the original function.
prj |
The normalized projections on eigenvectors) |
eVal |
The corresponding eigenvalues |
eVec |
The corresponding eigenvectors |
kcall |
The formula of the function called |
cndkernf |
The kernel function used |
xmatrix |
The original data matrix |
all the slots of the object can be accessed by accessor functions.
The predict function can be used to embed new data on the new space
Yusen Zhang
[email protected]
1.Baudat, G, and F. Anouar:
Generalized discriminant analysis using a kernel approach
Neural Computation 12.10(2000),2385
2.Deng Cai, Xiaofei He, and Jiawei Han:
Speed Up Kernel Discriminant Analysis
The VLDB Journal,January,2011,vol.20, no.1,21-33.
Iris <- data.frame(rbind(iris3[,,1], iris3[,,2], iris3[,,3]), Sp = rep(c("1","2","3"), rep(50,3))) testset <- sample(1:150,20) train <- as.matrix(iris[-testset,-5]) test <- as.matrix(iris[testset,-5]) Sp = rep(c("1","2","3"), rep(50,3)) labels <-as.numeric(Sp) trainlabel <- labels[-testset] testlabel <- labels[testset] kgda1 <- qkgda(train, label=trainlabel, kernel = "ratibase", qpar = list(c=1,q=0.9),features = 2) prj(kgda1) eVal(kgda1) eVec(kgda1) kcall(kgda1) # xmatrix(kgda1) #print the principal component vectors prj(kgda1) #plot the data projection on the components plot(kgda1@prj,col=as.integer(train), xlab="1st Principal Component",ylab="2nd Principal Component")
Iris <- data.frame(rbind(iris3[,,1], iris3[,,2], iris3[,,3]), Sp = rep(c("1","2","3"), rep(50,3))) testset <- sample(1:150,20) train <- as.matrix(iris[-testset,-5]) test <- as.matrix(iris[testset,-5]) Sp = rep(c("1","2","3"), rep(50,3)) labels <-as.numeric(Sp) trainlabel <- labels[-testset] testlabel <- labels[testset] kgda1 <- qkgda(train, label=trainlabel, kernel = "ratibase", qpar = list(c=1,q=0.9),features = 2) prj(kgda1) eVal(kgda1) eVec(kgda1) kcall(kgda1) # xmatrix(kgda1) #print the principal component vectors prj(kgda1) #plot the data projection on the components plot(kgda1@prj,col=as.integer(train), xlab="1st Principal Component",ylab="2nd Principal Component")
The qkernel Generalized Discriminant Analysis class
Objects can be created by calls of the form new("qkgda", ...)
.
or by calling the qkgda
function.
prj
:Object of class "matrix"
containing the normalized projections on eigenvectors
eVal
:Object of class "matrix"
containing the corresponding eigenvalues
eVec
:Object of class "matrix"
containing the corresponding eigenvectors
label
:Object of class "matrix"
containing the categorical variables that the categorical data be assigned to one of the categories
signature(object = "qkgda")
: returns the normalized projections
signature(object = "qkgda")
: returns the eigenvalues
signature(object = "qkgda")
: returns the eigenvectors
signature(object = "qkgda")
: returns the performed call
signature(object = "qkgda")
: returns the used kernel function
signature(object = "qkgda")
: embeds new data
signature(object = "qkgda")
: returns the used data matrix
Yusen Zhang
[email protected]
qkernel-class
,
cndkernel-class
Iris <- data.frame(rbind(iris3[,,1], iris3[,,2], iris3[,,3]), Sp = rep(c("1","2","3"), rep(50,3))) testset <- sample(1:150,20) train <- as.matrix(iris[-testset,-5]) test <- as.matrix(iris[testset,-5]) Sp = rep(c("1","2","3"), rep(50,3)) labels <-as.numeric(Sp) trainlabel <- labels[-testset] testlabel <- labels[testset] kgda1 <- qkgda(train, label=trainlabel, kernel = "ratibase", qpar = list(c=1,q=0.9),features = 2) prj(kgda1) eVal(kgda1) eVec(kgda1) cndkernf(kgda1) kcall(kgda1)
Iris <- data.frame(rbind(iris3[,,1], iris3[,,2], iris3[,,3]), Sp = rep(c("1","2","3"), rep(50,3))) testset <- sample(1:150,20) train <- as.matrix(iris[-testset,-5]) test <- as.matrix(iris[testset,-5]) Sp = rep(c("1","2","3"), rep(50,3)) labels <-as.numeric(Sp) trainlabel <- labels[-testset] testlabel <- labels[testset] kgda1 <- qkgda(train, label=trainlabel, kernel = "ratibase", qpar = list(c=1,q=0.9),features = 2) prj(kgda1) eVal(kgda1) eVec(kgda1) cndkernf(kgda1) kcall(kgda1)
Computes the Isomap embedding as introduced in 2000 by Tenenbaum, de Silva and Langford.
## S4 method for signature 'matrix' qkIsomap(x, kernel = "rbfbase", qpar = list(sigma = 0.1, q = 0.9), dims = 2, k, mod = FALSE, plotResiduals = FALSE, verbose = TRUE, na.action = na.omit, ...) ## S4 method for signature 'cndkernmatrix' qkIsomap(x, dims = 2, k, mod = FALSE, plotResiduals = FALSE, verbose = TRUE, na.action = na.omit, ...) ## S4 method for signature 'qkernmatrix' qkIsomap(x, dims = 2, k, mod = FALSE, plotResiduals = FALSE, verbose = TRUE, na.action = na.omit, ...)
## S4 method for signature 'matrix' qkIsomap(x, kernel = "rbfbase", qpar = list(sigma = 0.1, q = 0.9), dims = 2, k, mod = FALSE, plotResiduals = FALSE, verbose = TRUE, na.action = na.omit, ...) ## S4 method for signature 'cndkernmatrix' qkIsomap(x, dims = 2, k, mod = FALSE, plotResiduals = FALSE, verbose = TRUE, na.action = na.omit, ...) ## S4 method for signature 'qkernmatrix' qkIsomap(x, dims = 2, k, mod = FALSE, plotResiduals = FALSE, verbose = TRUE, na.action = na.omit, ...)
x |
N x D matrix (N samples, D features) or a kernel matrix of |
kernel |
the kernel function used in training and predicting. This parameter can be set to any function, of class kernel, which computes a kernel function value between two vector arguments. qkerntool provides the most popular kernel functions which can be used by setting the kernel parameter to the following strings:
The kernel parameter can also be set to a user defined function of class kernel by passing the function name as an argument. |
qpar |
the list of hyper-parameters (kernel parameters). This is a list which contains the parameters to be used with the kernel function. Valid parameters for existing kernels are :
Hyper-parameters for user defined kernels can be passed through the qpar parameter as well. |
dims |
vector containing the target space dimension(s) |
k |
number of neighbours |
mod |
use modified Isomap algorithm |
plotResiduals |
show a plot with the residuals between the high and the low dimensional data |
verbose |
show a summary of the embedding procedure at the end |
na.action |
A function to specify the action to be taken if |
... |
additional parameters |
The qkIsomap is a nonlinear dimension reduction technique, that preserves
global properties of the data. That means, that geodesic distances
between all samples are captured best in the low dimensional
embedding.
This R version is based on the Matlab implementation by Tenenbaum and
uses Floyd's Algorithm to compute the neighbourhood graph of shortest
distances, when calculating the geodesic distances.
A modified version of the original Isomap algorithm is included. It
respects nearest and farthest neighbours.
To estimate the intrinsic dimension of the data, the function can plot
the residuals between the high and the low dimensional data for a
given range of dimensions.
qkIsomap
gives out an S4 object which is a LIST with components
prj |
a N x dim matrix (N samples, dim features) with the reduced input data (list of several matrices if more than one dimension was specified). |
dims |
the dimension of the target space. |
Residuals |
the residual variances for all dimensions. |
eVal |
the corresponding eigenvalues. |
eVec |
the corresponding eigenvectors. |
cndkernf |
the kernel function used. |
kcall |
The formula of the function called |
all the slots of the object can be accessed by accessor functions.
Yusen Zhang
[email protected]
Tenenbaum, J. B. and de Silva, V. and Langford, J. C., "A global geometric framework for nonlinear dimensionality reduction.", 2000; Matlab code is available at http://waldron.stanford.edu/~isomap/
# another example using the iris data(iris) testset <- sample(1:150,20) train <- as.matrix(iris[-testset,-5]) labeltrain<- as.integer(iris[-testset,5]) test <- as.matrix(iris[testset,-5]) # ratibase(c=1,q=0.8) d_low = qkIsomap(train, kernel = "ratibase", qpar = list(c=1,q=0.8), dims=2, k=5, plotResiduals = TRUE) #plot the data projection on the components plot(prj(d_low),col=labeltrain, xlab="1st Principal Component",ylab="2nd Principal Component") prj(d_low) dims(d_low) Residuals(d_low) eVal(d_low) eVec(d_low) kcall(d_low) cndkernf(d_low)
# another example using the iris data(iris) testset <- sample(1:150,20) train <- as.matrix(iris[-testset,-5]) labeltrain<- as.integer(iris[-testset,5]) test <- as.matrix(iris[testset,-5]) # ratibase(c=1,q=0.8) d_low = qkIsomap(train, kernel = "ratibase", qpar = list(c=1,q=0.8), dims=2, k=5, plotResiduals = TRUE) #plot the data projection on the components plot(prj(d_low),col=labeltrain, xlab="1st Principal Component",ylab="2nd Principal Component") prj(d_low) dims(d_low) Residuals(d_low) eVal(d_low) eVec(d_low) kcall(d_low) cndkernf(d_low)
The qKernel Isometric Feature Mapping class
Objects can be created by calls of the form new("qkIsomap", ...)
.
or by calling the qkIsomap
function.
prj
:Object of class "matrix"
containing the Nxdim matrix (N samples, dim features) with the reduced input data (list of several matrices if more than one dimension specified)
dims
:Object of class "numeric"
containing the
dimension of the target space (default 2)
connum
:Object of class "numeric"
containing the number of connected components in graph
Residuals
:Object of class "vector"
containing the
residual variances for all dimensions
eVal
:Object of class "vector"
containing the corresponding eigenvalues
eVec
:Object of class "vector"
containing the corresponding eigenvectors
signature(object = "qkIsomap")
: returns the Nxdim
matrix (N samples, dim features)
signature(object = "qkIsomap")
: returns the
dimension
signature(object = "qkIsomap")
: returns the
residual variances
signature(object = "qkIsomap")
: returns the
eigenvalues
signature(object = "qkIsomap")
: returns the
eigenvectors
signature(object = "qkIsomap")
: returns the used
data matrix
signature(object = "qkIsomap")
: returns the
performed call
signature(object = "qkIsomapa")
: returns the used
kernel function
Yusen Zhang
[email protected]
qkernel-class
,
cndkernel-class
,
qkIsomap
# another example using the iris data data(iris) testset <- sample(1:150,20) train <- as.matrix(iris[-testset,-5]) labeltrain<- as.integer(iris[-testset,5]) test <- as.matrix(iris[testset,-5]) # ratibase(c=1,q=0.8) d_low = qkIsomap(train, kernel = "ratibase", qpar = list(c=1,q=0.8), dims=2, k=5, plotResiduals = TRUE) #plot the data projection on the components plot(prj(d_low),col=labeltrain, xlab="1st Principal Component",ylab="2nd Principal Component") prj(d_low) dims(d_low) Residuals(d_low) eVal(d_low) eVec(d_low) kcall(d_low) cndkernf(d_low)
# another example using the iris data data(iris) testset <- sample(1:150,20) train <- as.matrix(iris[-testset,-5]) labeltrain<- as.integer(iris[-testset,5]) test <- as.matrix(iris[testset,-5]) # ratibase(c=1,q=0.8) d_low = qkIsomap(train, kernel = "ratibase", qpar = list(c=1,q=0.8), dims=2, k=5, plotResiduals = TRUE) #plot the data projection on the components plot(prj(d_low),col=labeltrain, xlab="1st Principal Component",ylab="2nd Principal Component") prj(d_low) dims(d_low) Residuals(d_low) eVal(d_low) eVec(d_low) kcall(d_low) cndkernf(d_low)
Computes the qkernel Locally Linear Embedding
## S4 method for signature 'matrix' qkLLE(x, kernel = "rbfbase", qpar = list(sigma = 0.1, q = 0.9), dims = 2, k, na.action = na.omit, ...) ## S4 method for signature 'cndkernmatrix' qkLLE(x, dims = 2, k, na.action = na.omit, ...) ## S4 method for signature 'qkernmatrix' qkLLE(x, dims = 2, k, na.action = na.omit,...)
## S4 method for signature 'matrix' qkLLE(x, kernel = "rbfbase", qpar = list(sigma = 0.1, q = 0.9), dims = 2, k, na.action = na.omit, ...) ## S4 method for signature 'cndkernmatrix' qkLLE(x, dims = 2, k, na.action = na.omit, ...) ## S4 method for signature 'qkernmatrix' qkLLE(x, dims = 2, k, na.action = na.omit,...)
x |
N x D matrix (N samples, D features) or a kernel matrix of |
kernel |
the kernel function used in training and predicting. This parameter can be set to any function, of class kernel, which computes a kernel function value between two vector arguments. qkerntool provides the most popular kernel functions which can be used by setting the kernel parameter to the following strings:
The kernel parameter can also be set to a user defined function of class kernel by passing the function name as an argument. |
qpar |
the list of hyper-parameters (kernel parameters). This is a list which contains the parameters to be used with the kernel function. Valid parameters for existing kernels are :
Hyper-parameters for user defined kernels can be passed through the qpar parameter as well. |
dims |
dimension of the target space |
k |
the number of nearest neighbours. |
na.action |
A function to specify the action to be taken if |
... |
additional parameters |
The qkernel Locally Linear Embedding (qkLLE) preserves local properties of the data by
representing each sample in the data by a linear combination of
its k nearest neighbours with each neighbour weighted
independently. qkLLE finally chooses the low-dimensional
representation that best preserves the weights in the target
space. It is an extension of Locally Linear Embedding (LLE) with qkernel method.
It returns an S4 object containing the principal component vectors along with the corresponding eigenvalues.
prj |
a matrix with the reduced input data |
dims |
dimension of the target space |
eVal |
The corresponding eigenvalues |
eVec |
The corresponding eigenvectors |
cndkernf |
the kernel function used |
all the slots of the object can be accessed by accessor functions.
Yusen Zhang
[email protected]
Roweis, Sam T. and Saul, Lawrence K., "Nonlinear Dimensionality Reduction by Locally Linear Embedding",2000;
## S4 method for signature 'matrix' data(iris) testset <- sample(1:150,20) train <- as.matrix(iris[-testset,-5]) labeltrain<- as.integer(iris[-testset,5]) test <- as.matrix(iris[testset,-5]) plot(train ,col=labeltrain, xlab="1st Principal Component",ylab="2nd Principal Component") # ratibase(c=1,q=0.8) d_low <- qkLLE(train, kernel = "ratibase", qpar = list(c=1,q=0.8), dims=2, k=5) #plot the data projection on the components plot(prj(d_low),col=labeltrain, xlab="1st Principal Component",ylab="2nd Principal Component") ## S4 method for signature 'qkernmatrix' # ratibase(c=0.1,q=0.8) qkfunc <- ratibase(c=0.1,q=0.8) ktrain1 <- qkernmatrix(qkfunc,train) d_low <- qkLLE(ktrain1, dims = 2, k=5) #plot the data projection on the components plot(prj(d_low),col=labeltrain, xlab="1st Principal Component",ylab="2nd Principal Component")
## S4 method for signature 'matrix' data(iris) testset <- sample(1:150,20) train <- as.matrix(iris[-testset,-5]) labeltrain<- as.integer(iris[-testset,5]) test <- as.matrix(iris[testset,-5]) plot(train ,col=labeltrain, xlab="1st Principal Component",ylab="2nd Principal Component") # ratibase(c=1,q=0.8) d_low <- qkLLE(train, kernel = "ratibase", qpar = list(c=1,q=0.8), dims=2, k=5) #plot the data projection on the components plot(prj(d_low),col=labeltrain, xlab="1st Principal Component",ylab="2nd Principal Component") ## S4 method for signature 'qkernmatrix' # ratibase(c=0.1,q=0.8) qkfunc <- ratibase(c=0.1,q=0.8) ktrain1 <- qkernmatrix(qkfunc,train) d_low <- qkLLE(ktrain1, dims = 2, k=5) #plot the data projection on the components plot(prj(d_low),col=labeltrain, xlab="1st Principal Component",ylab="2nd Principal Component")
The qKernel Locally Linear Embedding class
Objects can be created by calls of the form new("qkLLE", ...)
.
or by calling the qkLLE
function.
prj
:Object of class "matrix"
containing the reduced input data
dims
:Object of class "numeric"
containing the
dimension of the target space (default 2)
eVal
:Object of class "vector"
containing the corresponding eigenvalues
eVec
:Object of class "matrix"
containing the corresponding eigenvectors
signature(object = "qkLLE")
: returns the reduced input data
signature(object = "qkLLE")
: returns the
dimension
signature(object = "qkLLE")
: returns the
eigenvalues
signature(object = "qkLLE")
: returns the
eigenvectors
signature(object = "qkLLE")
: returns the used
data matrix
signature(object = "qkLLE")
: returns the
performed call
signature(object = "qkLLE")
: returns the used
kernel function
Yusen Zhang
[email protected]
qkernel-class
,
cndkernel-class
## S4 method for signature 'matrix' data(iris) testset <- sample(1:150,20) train <- as.matrix(iris[-testset,-5]) labeltrain<- as.integer(iris[-testset,5]) test <- as.matrix(iris[testset,-5]) plot(train ,col=labeltrain, xlab="1st Principal Component",ylab="2nd Principal Component") # ratibase(c=1,q=0.8) d_low <- qkLLE(train, kernel = "ratibase", qpar = list(c=1,q=0.8), dims=2, k=5) #plot the data projection on the components plot(prj(d_low),col=labeltrain,xlab="1st Principal Component",ylab="2nd Principal Component") ## S4 method for signature 'qkernmatrix' # ratibase(c=0.1,q=0.8) qkfunc <- ratibase(c=0.1,q=0.8) ktrain1 <- qkernmatrix(qkfunc,train) d_low <- qkLLE(ktrain1, dims = 2, k=5) #plot the data projection on the components plot(prj(d_low),col=labeltrain,xlab="1st Principal Component",ylab="2nd Principal Component")
## S4 method for signature 'matrix' data(iris) testset <- sample(1:150,20) train <- as.matrix(iris[-testset,-5]) labeltrain<- as.integer(iris[-testset,5]) test <- as.matrix(iris[testset,-5]) plot(train ,col=labeltrain, xlab="1st Principal Component",ylab="2nd Principal Component") # ratibase(c=1,q=0.8) d_low <- qkLLE(train, kernel = "ratibase", qpar = list(c=1,q=0.8), dims=2, k=5) #plot the data projection on the components plot(prj(d_low),col=labeltrain,xlab="1st Principal Component",ylab="2nd Principal Component") ## S4 method for signature 'qkernmatrix' # ratibase(c=0.1,q=0.8) qkfunc <- ratibase(c=0.1,q=0.8) ktrain1 <- qkernmatrix(qkfunc,train) d_low <- qkLLE(ktrain1, dims = 2, k=5) #plot the data projection on the components plot(prj(d_low),col=labeltrain,xlab="1st Principal Component",ylab="2nd Principal Component")
The qkernel Metric Multi-Dimensional Scaling is a nonlinear form of Metric Multi-Dimensional Scaling
## S4 method for signature 'matrix' qkMDS(x, kernel = "rbfbase", qpar = list(sigma = 0.1, q = 0.9), dims = 2, plotResiduals = FALSE, verbose = TRUE, na.action = na.omit, ...) ## S4 method for signature 'cndkernmatrix' qkMDS(x, dims = 2,plotResiduals = FALSE, verbose = TRUE, na.action = na.omit, ...) ## S4 method for signature 'qkernmatrix' qkMDS(x, dims = 2,plotResiduals = FALSE, verbose = TRUE, na.action = na.omit, ...)
## S4 method for signature 'matrix' qkMDS(x, kernel = "rbfbase", qpar = list(sigma = 0.1, q = 0.9), dims = 2, plotResiduals = FALSE, verbose = TRUE, na.action = na.omit, ...) ## S4 method for signature 'cndkernmatrix' qkMDS(x, dims = 2,plotResiduals = FALSE, verbose = TRUE, na.action = na.omit, ...) ## S4 method for signature 'qkernmatrix' qkMDS(x, dims = 2,plotResiduals = FALSE, verbose = TRUE, na.action = na.omit, ...)
x |
N x D matrix (N samples, D features) or a kernel matrix of |
kernel |
the kernel function used in training and predicting. This parameter can be set to any function, of class kernel, which computes a kernel function value between two vector arguments. qkerntool provides the most popular kernel functions which can be used by setting the kernel parameter to the following strings:
The kernel parameter can also be set to a user defined function of class kernel by passing the function name as an argument. |
qpar |
the list of hyper-parameters (kernel parameters). This is a list which contains the parameters to be used with the kernel function. Valid parameters for existing kernels are :
Hyper-parameters for user defined kernels can be passed through the qpar parameter as well. |
dims |
vector containing the target space dimension(s) |
plotResiduals |
show a plot with the residuals between the high and the low dimensional data |
verbose |
show a summary of the embedding procedure at the end |
na.action |
A function to specify the action to be taken if |
... |
additional parameters |
There are several versions of non-metric multidimensional scaling in R, but qkerntool offers the following unique combination of using qKernel methods
qkMDS
gives out an S4 object which is a LIST with components
prj |
a N x dim matrix (N samples, dim features) with the reduced input data (list of several matrices if more than one dimension was specified). |
dims |
the dimension of the target space. |
Residuals |
the residual variances for all dimensions. |
eVal |
the corresponding eigenvalues. |
eVec |
the corresponding eigenvectors. |
cndkernf |
the kernel function used. |
kcall |
The formula of the function called |
all the slots of the object can be accessed by accessor functions.
Yusen Zhang
[email protected]
Kruskal, J.B. 1964a. Multidimensional scaling by optimizing goodness-of-fit to a nonmetric hypothesis. Psychometrika 29, 1–28.
# another example using the iris data(iris) testset <- sample(1:150,20) train <- as.matrix(iris[-testset,-5]) labeltrain<- as.integer(iris[-testset,5]) test <- as.matrix(iris[testset,-5]) # ratibase(c=1,q=0.8) d_low = qkMDS(train, kernel = "ratibase", qpar = list(c=1,q=0.9),dims = 2, plotResiduals = TRUE) #plot the data projection on the components plot(prj(d_low),col=labeltrain, xlab="1st Principal Component",ylab="2nd Principal Component") prj(d_low) dims(d_low) Residuals(d_low) eVal(d_low) eVec(d_low) kcall(d_low) cndkernf(d_low)
# another example using the iris data(iris) testset <- sample(1:150,20) train <- as.matrix(iris[-testset,-5]) labeltrain<- as.integer(iris[-testset,5]) test <- as.matrix(iris[testset,-5]) # ratibase(c=1,q=0.8) d_low = qkMDS(train, kernel = "ratibase", qpar = list(c=1,q=0.9),dims = 2, plotResiduals = TRUE) #plot the data projection on the components plot(prj(d_low),col=labeltrain, xlab="1st Principal Component",ylab="2nd Principal Component") prj(d_low) dims(d_low) Residuals(d_low) eVal(d_low) eVec(d_low) kcall(d_low) cndkernf(d_low)
The qkernel Metric Multi-Dimensional Scaling class
Objects can be created by calls of the form new("qkMDS", ...)
.
or by calling the qkMDS
function.
prj
:Object of class "matrix"
containing the Nxdim matrix (N samples, dim features) with the reduced input data (list of several matrices if more than one dimension specified)
dims
:Object of class "numeric"
containing the
dimension of the target space (default 2)
connum
:Object of class "numeric"
containing the number of connected components in graph
Residuals
:Object of class "vector"
containing the
residual variances for all dimensions
eVal
:Object of class "vector"
containing the corresponding eigenvalues
eVec
:Object of class "vector"
containing the corresponding eigenvectors
signature(object = "qkMDS")
: returns the Nxdim
matrix (N samples, dim features)
signature(object = "qkMDS")
: returns the
dimension
signature(object = "qkMDS")
: returns the
residual variances
signature(object = "qkMDS")
: returns the
eigenvalues
signature(object = "qkMDS")
: returns the
eigenvectors
signature(object = "qkMDS")
: returns the used
data matrix
signature(object = "qkMDS")
: returns the
performed call
signature(object = "qkMDS")
: returns the used
kernel function
Yusen Zhang
[email protected]
qkernel-class
,
cndkernel-class
,
qkMDS
# another example using the iris data(iris) testset <- sample(1:150,20) train <- as.matrix(iris[-testset,-5]) labeltrain<- as.integer(iris[-testset,5]) test <- as.matrix(iris[testset,-5]) # ratibase(c=1,q=0.8) d_low = qkMDS(train, kernel = "ratibase", qpar = list(c=1,q=0.8), dims=2, plotResiduals = TRUE) #plot the data projection on the components plot(prj(d_low),col=labeltrain, xlab="1st Principal Component",ylab="2nd Principal Component") prj(d_low) dims(d_low) Residuals(d_low) eVal(d_low) eVec(d_low) kcall(d_low) cndkernf(d_low)
# another example using the iris data(iris) testset <- sample(1:150,20) train <- as.matrix(iris[-testset,-5]) labeltrain<- as.integer(iris[-testset,5]) test <- as.matrix(iris[testset,-5]) # ratibase(c=1,q=0.8) d_low = qkMDS(train, kernel = "ratibase", qpar = list(c=1,q=0.8), dims=2, plotResiduals = TRUE) #plot the data projection on the components plot(prj(d_low),col=labeltrain, xlab="1st Principal Component",ylab="2nd Principal Component") prj(d_low) dims(d_low) Residuals(d_low) eVal(d_low) eVec(d_low) kcall(d_low) cndkernf(d_low)
The qkernel Principal Components Analysis is a nonlinear form of principal component analysis.
## S4 method for signature 'formula' qkpca(x, data = NULL, na.action, ...) ## S4 method for signature 'matrix' qkpca(x, kernel = "rbfbase", qpar = list(sigma = 0.1, q = 0.9), features = 0, th = 1e-4, na.action = na.omit, ...) ## S4 method for signature 'cndkernmatrix' qkpca(x, features = 0, th = 1e-4, ...) ## S4 method for signature 'qkernmatrix' qkpca(x, features = 0, th = 1e-4, ...)
## S4 method for signature 'formula' qkpca(x, data = NULL, na.action, ...) ## S4 method for signature 'matrix' qkpca(x, kernel = "rbfbase", qpar = list(sigma = 0.1, q = 0.9), features = 0, th = 1e-4, na.action = na.omit, ...) ## S4 method for signature 'cndkernmatrix' qkpca(x, features = 0, th = 1e-4, ...) ## S4 method for signature 'qkernmatrix' qkpca(x, features = 0, th = 1e-4, ...)
x |
the data matrix indexed by row, a formula describing the
model or a kernel matrix of |
data |
an optional data frame containing the variables in the model (when using a formula). |
kernel |
the kernel function used in training and predicting. This parameter can be set to any function, of class kernel, which computes a kernel function value between two vector arguments. qkerntool provides the most popular kernel functions which can be used by setting the kernel parameter to the following strings:
The kernel parameter can also be set to a user defined function of class kernel by passing the function name as an argument. |
qpar |
the list of hyper-parameters (kernel parameters). This is a list which contains the parameters to be used with the kernel function. Valid parameters for existing kernels are :
Hyper-parameters for user defined kernels can be passed through the qpar parameter as well. |
features |
Number of features (principal components) to return. (default: 0 , all) |
th |
the value of the eigenvalue under which principal components are ignored (only valid when features = 0). (default : 0.0001) |
na.action |
A function to specify the action to be taken if |
... |
additional parameters |
Using kernel functions one can efficiently compute
principal components in high-dimensional
feature spaces, related to input space by some non-linear map.
The data can be passed to the qkpca
function in a matrix
, in addition qkpca
also supports input in the form of a
kernel matrix of class qkernmatrix
or class cndkernmatrix
.
An S4 object containing the principal component vectors along with the corresponding eigenvalues.
pcv |
a matrix containing the principal component vectors (column wise) |
eVal |
The corresponding eigenvalues |
rotated |
The original data projected (rotated) on the principal components |
cndkernf |
the kernel function used |
xmatrix |
The original data matrix |
all the slots of the object can be accessed by accessor functions.
The predict function can be used to embed new data on the new space
Yusen Zhang
[email protected]
Schoelkopf B., A. Smola, K.-R. Mueller :
Nonlinear component analysis as a kernel eigenvalue problem
Neural Computation 10, 1299-1319
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.29.1366
# another example using the iris data data(iris) test <- sample(1:150,20) qkpc <- qkpca(~.,data=iris[-test,-5],kernel="rbfbase", qpar=list(sigma=50,q=0.8),features=2) # print the principal component vectors pcv(qkpc) #plot the data projection on the components plot(rotated(qkpc),col=as.integer(iris[-test,5]), xlab="1st Principal Component",ylab="2nd Principal Component") # embed remaining points emb <- predict(qkpc,iris[test,-5]) points(emb,col=as.integer(iris[test,5]))
# another example using the iris data data(iris) test <- sample(1:150,20) qkpc <- qkpca(~.,data=iris[-test,-5],kernel="rbfbase", qpar=list(sigma=50,q=0.8),features=2) # print the principal component vectors pcv(qkpc) #plot the data projection on the components plot(rotated(qkpc),col=as.integer(iris[-test,5]), xlab="1st Principal Component",ylab="2nd Principal Component") # embed remaining points emb <- predict(qkpc,iris[test,-5]) points(emb,col=as.integer(iris[test,5]))
The qkernel Principal Components Analysis class
Objects can be created by calls of the form new("qkpca", ...)
.
or by calling the qkpca
function.
pcv
:Object of class "matrix"
containing the
principal component vectors
eVal
:Object of class "vector"
containing the
corresponding eigenvalues
rotated
:Object of class "matrix"
containing the
projection of the data on the principal components
signature(object = "qkpca")
: returns the eigenvalues
signature(object = "qkpca")
: returns the principal
component vectors
signature(object = "qkpca")
: embeds new data
signature(object = "qkpca")
: returns the
projected data
signature(object = "qkpca")
: returns the used
data matrix
signature(object = "qkpca")
: returns the
performed call
signature(object = "qkpca")
: returns the used
kernel function
Yusen Zhang
[email protected]
qkernel-class
,
cndkernel-class
# another example using the iris data data(iris) test <- sample(1:150,20) qkpc <- qkpca(~.,iris[-test,-5], kernel = "rbfbase", qpar = list(sigma = 50, q = 0.8), features = 2) # print the principal component vectors pcv(qkpc) rotated(qkpc) cndkernf(qkpc) eVal(qkpc) xmatrix(qkpc) names(eVal(qkpc))
# another example using the iris data data(iris) test <- sample(1:150,20) qkpc <- qkpca(~.,iris[-test,-5], kernel = "rbfbase", qpar = list(sigma = 50, q = 0.8), features = 2) # print the principal component vectors pcv(qkpc) rotated(qkpc) cndkernf(qkpc) eVal(qkpc) xmatrix(qkpc) names(eVal(qkpc))
The qKernel Prehead class
Objects from the class cannot be created directly but only contained in other classes.
cndkernf
:Object of class "kfunction"
containing
the kernel function used
qpar
:Object of class "list"
containing the
kernel parameters used
xmatrix
:Object of class "input"
containing
the data matrix used
ymatrix
:Object of class "input"
containing
the data matrix used
kcall
:Object of class "ANY"
containing the
function call
terms
:Object of class "ANY"
containing the
function terms
n.action
:Object of class "ANY"
containing the
action performed on NA
signature(object = "qkprc")
: returns the used
kernel function
signature(object = "qkprc")
: returns the used
data matrix
signature(object = "qkprc")
: returns the used
data matrix
signature(object = "qkprc")
: returns the
performed call
Yusen Zhang
[email protected]
qkernel-class
,
cndkernel-class
A qkernel spectral clustering algorithm. Clustering is performed by embedding the data into the subspace of the eigenvectors of a graph Laplacian matrix.
## S4 method for signature 'matrix' qkspecc(x,kernel = "rbfbase", qpar = list(sigma = 2, q = 0.9), Nocent=NA, normalize="symmetric", maxk=20, iterations=200, na.action = na.omit, ...) ## S4 method for signature 'cndkernmatrix' qkspecc(x, Nocent=NA, normalize="symmetric", maxk=20,iterations=200, ...) ## S4 method for signature 'qkernmatrix' qkspecc(x, Nocent=NA, normalize="symmetric", maxk=20,iterations=200, ...)
## S4 method for signature 'matrix' qkspecc(x,kernel = "rbfbase", qpar = list(sigma = 2, q = 0.9), Nocent=NA, normalize="symmetric", maxk=20, iterations=200, na.action = na.omit, ...) ## S4 method for signature 'cndkernmatrix' qkspecc(x, Nocent=NA, normalize="symmetric", maxk=20,iterations=200, ...) ## S4 method for signature 'qkernmatrix' qkspecc(x, Nocent=NA, normalize="symmetric", maxk=20,iterations=200, ...)
x |
the matrix of data to be clustered or a kernel Matrix of class
|
kernel |
the kernel function used in computing the affinity matrix. This parameter can be set to any function, of class kernel, which computes a kernel function value between two vector arguments. kernlab provides the most popular kernel functions which can be used by setting the kernel parameter to the following strings:
The kernel parameter can also be set to a user defined function of class kernel by passing the function name as an argument. |
qpar |
a character string or the list of hyper-parameters (kernel parameters).
The default character string
Hyper-parameters for user defined kernels can be passed through the qpar parameter as well. |
Nocent |
the number of clusters. |
normalize |
Normalisation of the Laplacian ("none", "symmetric" or "random-walk"). |
maxk |
If k is NA, an upper bound for the automatic estimation. Defaults to 20. |
iterations |
the maximum number of iterations allowed. |
na.action |
the action to perform on NA. |
... |
additional parameters. |
The qkernel spectral clustering works by embedding the data points of the
partitioning problem into the subspace of the eigenvectors corresponding to the
smallest eigenvalues of the graph Laplacian matrix. Using a simple clustering method like
kmeans
on the embedded points usually leads to good performance. It can be shown that
qkernel spectral clustering methods boil down to graph partitioning.
The data can be passed to the qkspecc
function in a matrix
,
in addition qkspecc
also supports input in the form of a
kernel matrix of class qkernmatrix
or cndkernmatrix
.
An S4 object of class qkspecc
which extends the class vector
containing integers indicating the cluster to which
each point is allocated. The following slots contain useful information
clust |
The cluster assignments |
eVec |
The corresponding eigenvector |
eVal |
The corresponding eigenvalues |
ymatrix |
The eigenvectors corresponding to the |
Yusen Zhang
[email protected]
Andrew Y. Ng, Michael I. Jordan, Yair Weiss
On Spectral Clustering: Analysis and an Algorithm
Neural Information Processing Symposium 2001
qkernmatrix
, cndkernmatrix
, qkpca
data("iris") x=as.matrix(iris[,-5]) qspe <- qkspecc(x,kernel = "rbfbase", qpar = list(sigma = 10, q = 0.9), Nocent=3, normalize="symmetric", maxk=15, iterations=1200) plot(x, col = clust(qspe)) qkfunc <- nonlbase(alpha=1/15,q=0.8) Ktrain <- qkernmatrix(qkfunc, x) qspe <- qkspecc(Ktrain, Nocent=3, normalize="symmetric", maxk=20) plot(x, col = clust(qspe))
data("iris") x=as.matrix(iris[,-5]) qspe <- qkspecc(x,kernel = "rbfbase", qpar = list(sigma = 10, q = 0.9), Nocent=3, normalize="symmetric", maxk=15, iterations=1200) plot(x, col = clust(qspe)) qkfunc <- nonlbase(alpha=1/15,q=0.8) Ktrain <- qkernmatrix(qkfunc, x) qspe <- qkspecc(Ktrain, Nocent=3, normalize="symmetric", maxk=20) plot(x, col = clust(qspe))
The qKernel Spectral Clustering Class
Objects can be created by calls of the form new("qkspecc", ...)
.
or by calling the function qkspecc
.
clust
:Object of class "vector"
containing the cluster assignments
eVec
:Object of class "matrix"
containing
the corresponding eigenvector in each cluster
eVal
:Object of class "vector"
containing
the corresponding eigenvalue for each cluster
withinss
:Object of class "vector"
containing
the within-cluster sum of squares for each cluster
signature(object = "qkspecc")
: returns the cluster assignments
signature(object = "qkspecc")
: returns the corresponding eigenvector in each cluster
signature(object = "qkspecc")
: returns the corresponding eigenvalue for each cluster
signature(object = "qkspecc")
: returns the original data matrix or a kernel Matrix
signature(object = "qkspecc")
: returns The eigenvectors corresponding to the smallest eigenvalues of the graph Laplacian matrix.
signature(object = "qkspecc")
: returns the used kernel function
signature(object = "qkspecc")
: returns the performed call
Yusen Zhang
[email protected]
qkspecc
, qkernel-class
,
cndkernel-class
## Cluster the iris data set. data("iris") x=as.matrix(iris[,-5]) qspe <- qkspecc(x,kernel = "rbfbase", qpar = list(sigma = 10, q = 0.9), Nocent=3, normalize="symmetric", maxk=15, iterations=1200) clust(qspe) eVec(qspe) eVal(qspe) xmatrix(qspe) ymatrix(qspe) cndkernf(qspe)
## Cluster the iris data set. data("iris") x=as.matrix(iris[,-5]) qspe <- qkspecc(x,kernel = "rbfbase", qpar = list(sigma = 10, q = 0.9), Nocent=3, normalize="symmetric", maxk=15, iterations=1200) clust(qspe) eVec(qspe) eVal(qspe) xmatrix(qspe) ymatrix(qspe) cndkernf(qspe)
This is also a qkernel spectral clustering algorithm which uses three ways to assign labels after the laplacian embedding: kmeans, hclust and dbscan.
## S4 method for signature 'qkspecc' qkspeclust(x, clustmethod = "kmeans", Nocent=NULL,iterations=NULL, hmethod=NULL,eps = NULL, MinPts = NULL)
## S4 method for signature 'qkspecc' qkspeclust(x, clustmethod = "kmeans", Nocent=NULL,iterations=NULL, hmethod=NULL,eps = NULL, MinPts = NULL)
x |
object of class |
clustmethod |
the strategy to use to assign labels in the embedding space. There are three ways to assign labels after the laplacian embedding: kmeans, hclust and dbscan. |
Nocent |
the number of clusters |
iterations |
the maximum number of iterations allowed for "kmeans". |
hmethod |
the agglomeration method for "hclust". This should be (an unambiguous abbreviation of) one of "ward.D", "ward.D2", "single", "complete", "average" (= UPGMA), "mcquitty" (= WPGMA), "median" (= WPGMC) or "centroid" (= UPGMC). |
eps |
Reachability distance for "dbscan". |
MinPts |
Reachability minimum no. of points for "dbscan". |
The qkernel spectral clustering works by embedding the data points of the
partitioning problem into the subspace of the eigenvectors corresponding to the
smallest eigenvalues of the graph Laplacian matrix.
Using the simple clustering methods like
kmeans
, hclust
and dbscan
on the embedded points usually leads to good performance. It can be shown that
qkernel spectral clustering methods boil down to graph partitioning.
An S4 object of class qkspecc
which extends the class vector
containing integers indicating the cluster to which
each point is allocated. The following slots contain useful information
clust |
The cluster assignments |
eVec |
The corresponding eigenvector |
eVal |
The corresponding eigenvalues |
xmatrix |
The original data matrix |
ymatrix |
The real valued matrix of eigenvectors corresponding to the k smallest eigenvalues of the graph Laplacian matrix |
cndkernf |
The kernel function used |
Yusen Zhang
[email protected]
Andrew Y. Ng, Michael I. Jordan, Yair Weiss
On Spectral Clustering: Analysis and an Algorithm
Neural Information Processing Symposium 2001
qkernmatrix
, cndkernmatrix
, qkspecc-class
, qkspecc
data("iris") x=as.matrix(iris[ ,-5]) qspe <- qkspecc(x,kernel = "rbfbase", qpar = list(sigma = 90, q = 0.9), Nocent=3, normalize="symmetric", maxk=15,iterations=1200) plot(x, col = clust(qspe)) qspec <- qkspeclust(qspe,clustmethod = "hclust", Nocent=3, hmethod="ward.D2") plot(x, col = clust(qspec)) plot(qspec)
data("iris") x=as.matrix(iris[ ,-5]) qspe <- qkspecc(x,kernel = "rbfbase", qpar = list(sigma = 90, q = 0.9), Nocent=3, normalize="symmetric", maxk=15,iterations=1200) plot(x, col = clust(qspe)) qspec <- qkspeclust(qspe,clustmethod = "hclust", Nocent=3, hmethod="ward.D2") plot(x, col = clust(qspec)) plot(qspec)
The qkernel Sammon Mapping is an implementation for Sammon mapping, one of the earliest dimension reduction techniques that aims to find low-dimensional embedding that preserves pairwise distance structure in high-dimensional data space. qsammon is a nonlinear form of Sammon Mapping.
## S4 method for signature 'matrix' qsammon(x, kernel = "rbfbase", qpar = list(sigma = 0.5, q = 0.9), dims = 2, Initialisation = 'random', MaxHalves = 20, MaxIter = 500, TolFun = 1e-7, na.action = na.omit, ...) ## S4 method for signature 'cndkernmatrix' qsammon(cndkernel, x, k, dims = 2, Initialisation = 'random', MaxHalves = 20,MaxIter = 500, TolFun = 1e-7, ...) ## S4 method for signature 'qkernmatrix' qsammon(qkernel, x, k, dims = 2, Initialisation = 'random', MaxHalves = 20, MaxIter = 500, TolFun = 1e-7, ...)
## S4 method for signature 'matrix' qsammon(x, kernel = "rbfbase", qpar = list(sigma = 0.5, q = 0.9), dims = 2, Initialisation = 'random', MaxHalves = 20, MaxIter = 500, TolFun = 1e-7, na.action = na.omit, ...) ## S4 method for signature 'cndkernmatrix' qsammon(cndkernel, x, k, dims = 2, Initialisation = 'random', MaxHalves = 20,MaxIter = 500, TolFun = 1e-7, ...) ## S4 method for signature 'qkernmatrix' qsammon(qkernel, x, k, dims = 2, Initialisation = 'random', MaxHalves = 20, MaxIter = 500, TolFun = 1e-7, ...)
x |
the data matrix indexed by row or a kernel matrix of |
kernel |
the kernel function used in training and predicting. This parameter can be set to any function, of class kernel, which computes a kernel function value between two vector arguments. qkerntool provides the most popular kernel functions which can be used by setting the kernel parameter to the following strings:
The kernel parameter can also be set to a user defined function of class kernel by passing the function name as an argument. |
qpar |
the list of hyper-parameters (kernel parameters). This is a list which contains the parameters to be used with the kernel function. Valid parameters for existing kernels are :
Hyper-parameters for user defined kernels can be passed through the qpar parameter as well. |
qkernel |
the kernel function to be used to calculate the qkernel matrix. |
cndkernel |
the cndkernel function to be used to calculate the CND kernel matrix. |
k |
the dimension of the original data. |
dims |
Number of features to return. (default: 2) |
Initialisation |
|
MaxHalves |
maximum number of step halvings. (default : 20) |
MaxIter |
the maximum number of iterations allowed. (default : 500) |
TolFun |
relative tolerance on objective function. (default : 1e-7) |
na.action |
A function to specify the action to be taken if |
... |
additional parameters |
Using kernel functions one can efficiently compute
principal components in high-dimensional
feature spaces, related to input space by some non-linear map.
The data can be passed to the qsammon
function in a matrix
, in addition qsammon
also supports input in the form of a
kernel matrix of class qkernmatrix
or class cndkernmatrix
.
dimRed |
The matrix whose rows are embedded observations. |
kcall |
The function call contained |
cndkernf |
The kernel function used |
all the slots of the object can be accessed by accessor functions.
Yusen Zhang
[email protected]
Sammon, J.W. (1969) A Nonlinear Mapping for Data Structure Analysis. IEEE Transactions on Computers, C-18 5:401-409.
data(iris) train <- as.matrix(iris[,1:4]) labeltrain<- as.integer(iris[,5]) ## S4 method for signature 'matrix' kpc2 <- qsammon(train, kernel = "rbfbase", qpar = list(sigma = 2, q = 0.9), dims = 2, Initialisation = 'pca', TolFun = 1e-5) plot(dimRed(kpc2), col = as.integer(labeltrain)) cndkernf(kpc2)
data(iris) train <- as.matrix(iris[,1:4]) labeltrain<- as.integer(iris[,5]) ## S4 method for signature 'matrix' kpc2 <- qsammon(train, kernel = "rbfbase", qpar = list(sigma = 2, q = 0.9), dims = 2, Initialisation = 'pca', TolFun = 1e-5) plot(dimRed(kpc2), col = as.integer(labeltrain)) cndkernf(kpc2)
The qKernel Sammon Mapping class
Objects can be created by calls of the form new("qsammon", ...)
.
or by calling the qsammon
function.
dimRed
:Object of class "matrix"
containing the
matrix whose rows are embedded observations
cndkernf
:Object of class "function"
containing
the kernel function used
kcall
:Object of class "ANY"
containing the
function call
signature(object = "qsammon")
: returns the matrix whose rows are embedded observations
signature(object = "qsammon")
: returns the
performed call
signature(object = "qsammon")
: returns the used
kernel function
Yusen Zhang
[email protected]
data(iris) train <- as.matrix(iris[,1:4]) labeltrain<- as.integer(iris[,5]) ## S4 method for signature 'matrix' qkpc <- qsammon(train, kernel = "rbfbase", qpar = list(sigma = 0.5, q = 0.9), dims = 2, Initialisation = 'pca', MaxHalves = 50) cndkernf(qkpc) dimRed(qkpc) kcall(qkpc)
data(iris) train <- as.matrix(iris[,1:4]) labeltrain<- as.integer(iris[,5]) ## S4 method for signature 'matrix' qkpc <- qsammon(train, kernel = "rbfbase", qpar = list(sigma = 0.5, q = 0.9), dims = 2, Initialisation = 'pca', MaxHalves = 50) cndkernf(qkpc) dimRed(qkpc) kcall(qkpc)
Wrapper for the qkernel t-distributed stochastic neighbor embeddingg. qtSNE is a method for constructing a low dimensional embedding of high-dimensional data, distances or similarities.
## S4 method for signature 'matrix' qtSNE(x,kernel = "rbfbase", qpar = list(sigma = 0.1, q = 0.9), initial_config = NULL, no_dims=2, initial_dims=30, perplexity=30, max_iter= 1300, min_cost=0, epoch_callback=NULL, epoch=100, na.action = na.omit, ...) ## S4 method for signature 'cndkernmatrix' qtSNE(x,initial_config = NULL, no_dims=2, initial_dims=30, perplexity=30, max_iter = 1000, min_cost=0, epoch_callback=NULL,epoch=100) ## S4 method for signature 'qkernmatrix' qtSNE(x,initial_config = NULL, no_dims=2, initial_dims=30, perplexity=30, max_iter = 1000, min_cost=0, epoch_callback=NULL,epoch=100)
## S4 method for signature 'matrix' qtSNE(x,kernel = "rbfbase", qpar = list(sigma = 0.1, q = 0.9), initial_config = NULL, no_dims=2, initial_dims=30, perplexity=30, max_iter= 1300, min_cost=0, epoch_callback=NULL, epoch=100, na.action = na.omit, ...) ## S4 method for signature 'cndkernmatrix' qtSNE(x,initial_config = NULL, no_dims=2, initial_dims=30, perplexity=30, max_iter = 1000, min_cost=0, epoch_callback=NULL,epoch=100) ## S4 method for signature 'qkernmatrix' qtSNE(x,initial_config = NULL, no_dims=2, initial_dims=30, perplexity=30, max_iter = 1000, min_cost=0, epoch_callback=NULL,epoch=100)
x |
the matrix of data to be clustered or a kernel Matrix of class
|
kernel |
the kernel function used in computing the affinity matrix. This parameter can be set to any function, of class kernel, which computes a kernel function value between two vector arguments. kernlab provides the most popular kernel functions which can be used by setting the kernel parameter to the following strings:
The kernel parameter can also be set to a user defined function of class kernel by passing the function name as an argument. |
qpar |
a character string or the list of hyper-parameters (kernel parameters).
The default character string
Hyper-parameters for user defined kernels can be passed through the qkpar parameter as well. |
initial_config |
An intitial configure about x (default: NULL) |
no_dims |
the dimension of the resulting embedding. (default: 2) |
initial_dims |
The number of dimensions to use in reduction method. (default: 30) |
perplexity |
Perplexity parameter |
max_iter |
Number of iterations (default: 1300) |
min_cost |
The minimum cost for every object after the final iteration |
epoch_callback |
A callback function used after each epoch (an epoch here means a set number of iterations) |
epoch |
The interval of the number of iterations displayed (default: 100) |
na.action |
the action to perform on NA |
... |
Other arguments that can be passed to qtSNE |
When the initial_config argument is specified, the algorithm will automatically enter the final momentum stage. This stage has less large scale adjustment to the embedding, and is intended for small scale tweaking of positioning. This can greatly speed up the generation of embeddings for various similar X datasets, while also preserving overall embedding orientation.
qtSNE
gives out an S4 object which is a LIST with components
dimRed |
Matrix containing the new representations for the objects after qtSNE |
cndkernf |
The kernel function used |
Yusen Zhang
[email protected]
Maaten, L. Van Der, 2014. Accelerating t-SNE using Tree-Based Algorithms. Journal of Machine Learning Research, 15, p.3221-3245.
van der Maaten, L.J.P. & Hinton, G.E., 2008. Visualizing High-Dimensional Data Using t-SNE. Journal of Machine Learning Research, 9, pp.2579-2605.
## Not run: #use iris data set data(iris) testset <- sample(1:150,20) train <- as.matrix(iris[,1:4]) colors = rainbow(length(unique(iris$Species))) names(colors) = unique(iris$Species) #for matrix ecb = function(x,y){ plot(x,t='n'); text(x,labels=iris$Species, col=colors[iris$Species]) } kpc2 <- qtSNE(train, kernel = "rbfbase", qpar = list(sigma=1,q=0.8), epoch_callback = ecb, perplexity=10, max_iter = 500) ## End(Not run)
## Not run: #use iris data set data(iris) testset <- sample(1:150,20) train <- as.matrix(iris[,1:4]) colors = rainbow(length(unique(iris$Species))) names(colors) = unique(iris$Species) #for matrix ecb = function(x,y){ plot(x,t='n'); text(x,labels=iris$Species, col=colors[iris$Species]) } kpc2 <- qtSNE(train, kernel = "rbfbase", qpar = list(sigma=1,q=0.8), epoch_callback = ecb, perplexity=10, max_iter = 500) ## End(Not run)
An S4 Class for qtSNE.
The qtSNE is a method that uses Qkernel t-Distributed Stochastic Neighborhood Embedding between the distance matrices in high and low-dimensional space to embed the data. The method is very well suited to visualize complex structures in low dimensions.
Objects can be created by calls of the form new("qtSNE", ...)
.
or by calling the function qtSNE
.
dimRed
Matrix containing the new representations for the objects after qtSNE
cndkernf
The kernel function used
dimRed
signature(object="qtSNE")
: return a new representation matrix
cndkernf
signature(object="qtSNE")
: return the kernel used
Yusen Zhang
[email protected]
Maaten, L. van der, 2014. Accelerating t-SNE using Tree-Based Algorithms. Journal of Machine Learning Research 15, 3221-3245.
van der Maaten, L., Hinton, G., 2008. Visualizing Data using t-SNE. J. Mach. Learn. Res. 9, 2579-2605.
## Not run: #use iris data set data(iris) testset <- sample(1:150,20) train <- as.matrix(iris[,1:4]) colors = rainbow(length(unique(iris$Species))) names(colors) = unique(iris$Species) #for matrix ecb = function(x,y){ plot(x,t='n'); text(x,labels=iris$Species, col=colors[iris$Species]) } kpc2 <- qtSNE(train, kernel = "rbfbase", qpar = list(sigma=1,q=0.8), epoch_callback = ecb, perplexity=10, max_iter = 500) #cndernf cndkernf(kpc2) #dimRed plot(dimRed(kpc2),col=train) ## End(Not run)
## Not run: #use iris data set data(iris) testset <- sample(1:150,20) train <- as.matrix(iris[,1:4]) colors = rainbow(length(unique(iris$Species))) names(colors) = unique(iris$Species) #for matrix ecb = function(x,y){ plot(x,t='n'); text(x,labels=iris$Species, col=colors[iris$Species]) } kpc2 <- qtSNE(train, kernel = "rbfbase", qpar = list(sigma=1,q=0.8), epoch_callback = ecb, perplexity=10, max_iter = 500) #cndernf cndkernf(kpc2) #dimRed plot(dimRed(kpc2),col=train) ## End(Not run)