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 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 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 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)
the matrix of data to be clustered or a kernel Matrix of class
qkernmatrix
or cndkernmatrix
.
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:
rbfbase
Radial Basis qkernel function "Gaussian"
nonlbase
Non Linear qkernel function
laplbase
Laplbase qkernel function
ratibase
Rational Quadratic qkernel function
multbase
Multiquadric qkernel function
invbase
Inverse Multiquadric qkernel function
wavbase
Wave qkernel function
powbase
Power qkernel function
logbase
Log qkernel function
caubase
Cauchy qkernel function
chibase
Chi-Square qkernel function
studbase
Generalized T-Student qkernel function
nonlcnd
Non Linear cndkernel function
polycnd
Polynomial cndkernel function
rbfcnd
Radial Basis cndkernel function "Gaussian"
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
Power cndkernel function
logcnd
Log cndkernel function
caucnd
Cauchy cndkernel function
chicnd
Chi-Square cndkernel function
studcnd
Generalized T-Student cndkernel function
The kernel parameter can also be set to a user defined function of class kernel by passing the function name as an argument.
a character string or the list of hyper-parameters (kernel parameters).
The default character string list(sigma = 2, q = 0.9)
uses a heuristic to determine a
suitable value for the width parameter of the RBF kernel.
The second option "local"
(local scaling) uses a more advanced heuristic
and sets a width parameter for every point in the data set. This is
particularly useful when the data incorporates multiple scales.
A list can also be used containing the parameters to be used with the
kernel function. Valid parameters for existing kernels are :
sigma
for the Radial Basis qkernel function "rbfbase" , the Laplacian qkernel function "laplbase" the Cauchy qkernel function "caubase" and for the ANOVA cndkernel function "anocnd".
alpha
for the Non Linear qkernel function "nonlbase",for the Non Linear cndkernel function "nonlcnd",and for the Polynomial cndkernel function "polycnd".
c
for the Rational Quadratic qkernel function "ratibase" , the Multiquadric qkernel function "multbase", the Inverse Multiquadric qkernel function "invbase",for the Polynomial cndkernel function "polycnd",for the Rational Quadratic cndkernel function "raticnd" , the Multiquadric cndkernel function "multcnd" and the Inverse Multiquadric cndkernel function "invcnd".
d
for qkernel function "powbase" , the Log qkernel function "logbase", the Generalized T-Student qkernel function "studbase", for the Polynomial cndkernel function "polycnd", for the ANOVA cndkernel function "anocnd",for the d cndkernel function "powcnd" , the Log cndkernel function "logcnd" and the Generalized T-Student cndkernel function "studcnd".
theta
for the Wave qkernel function "wavbase" and for the Wave cndkernel function "wavcnd".
gamma
for the Chi-Square qkernel function "chibase",for the Radial Basis cndkernel function "rbfcnd" and the Laplacian cndkernel function "laplcnd" and the Cauchy cndkernel function "caucnd".
q
For all qkernel Function.
where length is the length of the strings considered, lambda the
decay factor and normalized a logical parameter determining if the
kernel evaluations should be normalized.
Hyper-parameters for user defined kernels can be passed through the qkpar parameter as well.
An intitial configure about x (default: NULL)
the dimension of the resulting embedding. (default: 2)
The number of dimensions to use in reduction method. (default: 30)
Perplexity parameter
Number of iterations (default: 1300)
The minimum cost for every object after the final iteration
A callback function used after each epoch (an epoch here means a set number of iterations)
The interval of the number of iterations displayed (default: 100)
the action to perform on NA
Other arguments that can be passed to qtSNE
qtSNE
gives out an S4 object which is a LIST with components
Matrix containing the new representations for the objects after qtSNE
The kernel function used
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.
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)
# }
Run the code above in your browser using DataLab