Learn R Programming

SSL (version 0.1)

sslLapRLS: Laplacian Regularized Least Squares

Description

Laplacian Regularized Least Squares

Usage

sslLapRLS(xl, yl, xu, graph.type = "exp", dist.type = "Euclidean", alpha, alpha1, alpha2, k, epsilon, kernel = "gaussian", c1, c2, c3, deg, gamma, alpha3, alpha4, gammaA = 1, gammaI = 1)

Arguments

xl
a n * p matrix or data.frame of labeled data.
yl
a n * 1 binary labels(1 or -1).
xu
a m * p matrix or data.frame of unlabeled data.
graph.type
character string; which type of graph should be created? Options include knn,enn,tanh and exp.
  • enn :epsilon-NN graphs. Nodes i, j are connected by an edge, if the distance d(i, j ) < epsilon. The hyperparameter epsilon controls neighborhood radius.
  • tanh:tanh-weighted graphs. w(i,j) = (tanh(alpha1(d(i,j) - alpha2)) + 1)/2.where d(i,j) denotes the distance between point i and j. Hyperparameters alpha1 and alpha2 control the slope and cutoff value respectively.
  • exp :exp-weighted graphs.w(i,j) = exp(-d(i,j)^2/alpha^2),where d(i,j) denotes the distance between point i and j. Hyperparameter alpha controls the decay rate.
dist.type
character string; this parameter controls the type of distance measurement.(see dist or pr_DB).
alpha
numeric parameter needed when graph.type = exp
alpha1
numeric parameter needed when graph.type = tanh
alpha2
numeric parameter needed when graph.type = tanh
k
integer parameter needed when graph.type = knn
epsilon
numeric parameter needed when graph.type = enn
kernel
character string; it controls four types of common kernel functions:linear,polynomial,gaussian and sigmoid.
  • polynomial:Polynomial kernel;k(x,y)=(alpha3 *dot(x,y)+c2)^deg,where dot(x,y) is the dot product of vector x and y.Adjustable parameters are the slope alpha3, the constant term c2 and the polynomial degree deg.
  • gaussian:Gaussian kernel;k(x,y)=exp(-gamma*d(x,y)^2),where d(x,y) is Euclidean distace between vector x and y,gamma is a slope parameter.
  • sigmoid:Hyperbolic Tangent (Sigmoid) Kernel;k(x,y)=tanh(alpha4*dot(x,y)+c3),where d(x,y) is dot product of vector x and y.There are two adjustable parameters in the sigmoid kernel, the slope alpha4 and the intercept constant c3.
c1
numeric parameter needed when kernel = linear
c2
numeric parameter needed when kernel = polynomial
c3
numeric parameter needed when kernel = sigmoid
deg
integer parameter needed when kernel = polynomial
gamma
numeric parameter needed when kernel = gaussian
alpha3
numeric parameter needed when kernel = polynomial
alpha4
numeric parameter needed when kernel = sigmoid
gammaA
numeric; model parameter.
gammaI
numeric; model parameter.

Value

a m * 1 integer vector representing the predicted labels of unlabeled data(1 or -1).

References

Olivier Chapelle, Bernhard Scholkopf and Alexander Zien (2006). Semi-Supervised Learning.The MIT Press.

See Also

pr_DB dist

Examples

Run this code
data(iris)
xl<-iris[c(1:20,51:70),-5]
xu<-iris[c(21:50,71:100),-5]
yl<-rep(c(1,-1),each=20)
# combinations of different graph types and kernel types
# graph.type =knn, kernel =linear
yu1<-sslLapRLS(xl,yl,xu,graph.type="knn",k=10,kernel="linear",c1=1)
# graph.type =knn, kernel =polynomial
yu2<-sslLapRLS(xl,yl,xu,graph.type="knn",k=10,kernel="polynomial",c2=1,deg=2,alpha3=1)
# graph.type =knn, kernel =gaussian
yu3<-sslLapRLS(xl,yl,xu,graph.type="knn",k=10,kernel="gaussian",gamma=1)
# graph.type =knn, kernel =sigmoid
yu4<-sslLapRLS(xl,yl,xu,graph.type="knn",k=10,kernel="sigmoid",c3=-10,
alpha4=0.001,gammaI  = 0.05,gammaA = 0.05)
# graph.type =enn, kernel =linear
yu5<-sslLapRLS(xl,yl,xu,graph.type="enn",epsilon=1,kernel="linear",c1=1)
# graph.type =enn, kernel =polynomial
yu6<-sslLapRLS(xl,yl,xu,graph.type="enn",epsilon=1,kernel="polynomial",c2=1,deg=2,alpha3=1)
# graph.type =enn, kernel =gaussian
yu7<-sslLapRLS(xl,yl,xu,graph.type="enn",epsilon=1,kernel="gaussian",gamma=1)
# graph.type =enn, kernel =sigmoid
yu8<-sslLapRLS(xl,yl,xu,graph.type="enn",epsilon=1,kernel="sigmoid",c3=-10,
alpha4=0.001,gammaI  = 0.05,gammaA = 0.05)
# graph.type =tanh, kernel =linear
yu9<-sslLapRLS(xl,yl,xu,graph.type="tanh",alpha1=-2,alpha2=1,kernel="linear",c1=1)
# graph.type =tanh, kernel =polynomial
yu10<-sslLapRLS(xl,yl,xu,graph.type="tanh",alpha1=-2,alpha2=1,
kernel="polynomial",c2=1,deg=2,alpha3=1)
# graph.type =tanh, kernel =gaussian
yu11<-sslLapRLS(xl,yl,xu,graph.type="tanh",alpha1=-2,alpha2=1,kernel="gaussian",gamma=1)
# graph.type =tanh, kernel =sigmoid
yu12<-sslLapRLS(xl,yl,xu,graph.type="tanh",alpha1=-2,alpha2=1,
kernel="sigmoid",c3=-10,alpha4=0.001,gammaI  = 0.05,gammaA = 0.05)
# graph.type =exp, kernel =linear
yu13<-sslLapRLS(xl,yl,xu,graph.type="exp",alpha=1,kernel="linear",c1=1)
# graph.type =exp, kernel =polynomial
yu14<-sslLapRLS(xl,yl,xu,graph.type="exp",alpha=1,kernel="polynomial",c2=1,deg=2,alpha3=1)
# graph.type =exp, kernel =gaussian
yu15<-sslLapRLS(xl,yl,xu,graph.type="exp",alpha=1,kernel="gaussian",gamma=1)
# graph.type =exp, kernel =sigmoid
yu16<-sslLapRLS(xl,yl,xu,graph.type="exp",alpha=1,kernel="sigmoid",
c3=-10,alpha4=0.001,gammaI  = 0.05,gammaA = 0.05)

Run the code above in your browser using DataLab