LaplacianSVMSSLR {SSLR} | R Documentation |
General Interface for LaplacianSVM model
Description
model from RSSL package 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).
Usage
LaplacianSVMSSLR(
lambda = 1,
gamma = 1,
scale = TRUE,
kernel = kernlab::vanilladot(),
adjacency_distance = "euclidean",
adjacency_k = 6,
normalized_laplacian = FALSE,
eps = 1e-09
)
Arguments
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 |
References
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.
Examples
library(tidyverse)
library(caret)
library(tidymodels)
library(SSLR)
data(breast)
set.seed(1)
train.index <- createDataPartition(breast$Class, p = .7, list = FALSE)
train <- breast[ train.index,]
test <- breast[-train.index,]
cls <- which(colnames(breast) == "Class")
#% LABELED
labeled.index <- createDataPartition(breast$Class, p = .2, list = FALSE)
train[-labeled.index,cls] <- NA
library(kernlab)
m <- LaplacianSVMSSLR(kernel=kernlab::vanilladot()) %>%
fit(Class ~ ., data = train)
#Accesing model from RSSL
model <- m$model
#Accuracy
predict(m,test) %>%
bind_cols(test) %>%
metrics(truth = "Class", estimate = .pred_class)