Learn R Programming

SSL (version 0.1)

sslLabelProp: Label Propagation

Description

sslLabelProp propagates a few known labels to a large number of unknown labels according to their proximities to neighboring nodes. It supports many kinds of distance measurements and graph representations.

Usage

sslLabelProp(x, y, known.label, graph.type = "exp", dist.type = "Euclidean", alpha, alpha1, alpha2, k, epsilon, iter = 1000)

Arguments

x
a n * p matrix or data.frame of n observations and p predictors
y
a vector of k known labels. The rows of y must be the same as the length of known.label.
known.label
a vector indicating the row index of known labels in matrix x.
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
iter
iteration

Value

a n * 1 vector indicating the predictions of n observations in C class

Details

sslLabelProp implements label propagation algorithm in iter iterations.It supports many kinds of distance measurements and four types of graph creations.

References

Xiaojin Zhu(2005),Semi-Supervised Learning with Graphs

See Also

dist, pr_DB

Examples

Run this code
data(iris)
x<-iris[,1:4]
#Suppose we know the first twenty observations of each class and we want to propagate
#these labels to unlabeled data.
# 1 setosa, 2 versicolor, 3 virginica
y<-rep(1:3,each =20)
known.label <-c(1:20,51:70,101:120)
f1<-sslLabelProp(x,y,known.label,graph.type="enn",epsilon = 0.5)
f2<-sslLabelProp(x,y,known.label,graph.type="knn",k =10)
f3<-sslLabelProp(x,y,known.label,graph.type="tanh",alpha1=-2,alpha2=1)
f4<-sslLabelProp(x,y,known.label,graph.type="exp",alpha = 1)

Run the code above in your browser using DataLab