Laplacian SVM classifier
Manifold regularization applied to the support vector machine as proposed in Belkin et al. (2006). As an adjacency matrix, we use the k nearest neighbour graph based on a chosen distance (default: euclidean).
LaplacianSVM(X, y, X_u = NULL, lambda = 1, gamma = 1, scale = TRUE, kernel = vanilladot(), adjacency_distance = "euclidean", adjacency_k = 6, normalized_laplacian = FALSE, eps = 1e-09)
X |
matrix; Design matrix for labeled data |
y |
factor or integer vector; Label vector |
X_u |
matrix; Design matrix for unlabeled data |
lambda |
numeric; L2 regularization parameter |
gamma |
numeric; Weight of the unlabeled data |
scale |
logical; Should the features be normalized? (default: FALSE) |
kernel |
kernlab::kernel to use |
adjacency_distance |
character; distance metric used to construct adjacency graph from the dist function. Default: "euclidean" |
adjacency_k |
integer; Number of of neighbours used to construct adjacency graph. |
normalized_laplacian |
logical; If TRUE use the normalized Laplacian, otherwise, the Laplacian is used |
eps |
numeric; Small value to ensure positive definiteness of the matrix in the QP formulation |
S4 object of type LaplacianSVM
Belkin, M., Niyogi, P. & Sindhwani, V., 2006. Manifold regularization: A geometric framework for learning from labeled and unlabeled examples. Journal of Machine Learning Research, 7, pp.2399-2434.
Other RSSL classifiers:
EMLeastSquaresClassifier
,
EMLinearDiscriminantClassifier
,
GRFClassifier
,
ICLeastSquaresClassifier
,
ICLinearDiscriminantClassifier
,
KernelLeastSquaresClassifier
,
LaplacianKernelLeastSquaresClassifier()
,
LeastSquaresClassifier
,
LinearDiscriminantClassifier
,
LinearSVM
,
LinearTSVM()
,
LogisticLossClassifier
,
LogisticRegression
,
MCLinearDiscriminantClassifier
,
MCNearestMeanClassifier
,
MCPLDA
,
MajorityClassClassifier
,
NearestMeanClassifier
,
QuadraticDiscriminantClassifier
,
S4VM
,
SVM
,
SelfLearning
,
TSVM
,
USMLeastSquaresClassifier
,
WellSVM
,
svmlin()
library(RSSL) library(ggplot2) library(dplyr) ## Example 1: Half moons # Generate a dataset set.seed(2) df_orig <- generateCrescentMoon(100,sigma = 0.3) df <- df_orig %>% add_missinglabels_mar(Class~.,0.98) lambda <- 0.001 C <- 1/(lambda*2*sum(!is.na(df$Class))) gamma <- 10000 rbf_param <- 0.125 # Train classifiers class_sup <- SVM( Class~.,df, kernel=kernlab::rbfdot(rbf_param), C=C,scale=FALSE) class_lap <- LaplacianSVM( Class~.,df, kernel=kernlab::rbfdot(rbf_param), lambda=lambda,gamma=gamma, normalized_laplacian = TRUE, scale=FALSE) classifiers <- list("Lap"=class_lap,"Sup"=class_sup) # This takes a little longer to run: # class_tsvm <- TSVM( # Class~.,df, # kernel=kernlab::rbfdot(rbf_param), # C=C,Cstar=10,s=-0.8, # scale=FALSE,balancing_constraint=TRUE) # classifiers <- list("Lap"=class_lap,"Sup"=class_sup,"TSVM"=class_tsvm) # Plot classifiers (Can take a couple of seconds) ## Not run: df %>% ggplot(aes(x=X1,y=X2,color=Class)) + geom_point() + coord_equal() + stat_classifier(aes(linetype=..classifier..), classifiers = classifiers , color="black") ## End(Not run) # Calculate the loss lapply(classifiers,function(c) mean(loss(c,df_orig))) ## Example 2: Two circles set.seed(3) df_orig <- generateTwoCircles(1000,noise=0.05) df <- df_orig %>% add_missinglabels_mar(Class~.,0.994) lambda <- 0.000001 C <- 1/(lambda*2*sum(!is.na(df$Class))) gamma <- 100 rbf_param <- 0.1 # Train classifiers (Takes a couple of seconds) ## Not run: class_sup <- SVM( Class~.,df, kernel=kernlab::rbfdot(rbf_param), C=C,scale=FALSE) class_lap <- LaplacianSVM( Class~.,df, kernel=kernlab::rbfdot(rbf_param), adjacency_k=50, lambda=lambda,gamma=gamma, normalized_laplacian = TRUE, scale=FALSE) classifiers <- list("Lap"=class_lap,"Sup"=class_sup) ## End(Not run) # Plot classifiers (Can take a couple of seconds) ## Not run: df %>% ggplot(aes(x=X1,y=X2,color=Class,size=Class)) + scale_size_manual(values=c("1"=3,"2"=3),na.value=1) + geom_point() + coord_equal() + stat_classifier(aes(linetype=..classifier..), classifiers = classifiers , color="black",size=1) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.