GRFClassifierSSLR.Rdmodel from RSSL package Implements the approach proposed in Zhu et al. (2003) to label propagation over an affinity graph. Note, as in the original paper, we consider the transductive scenario, so the implementation does not generalize to out of sample predictions. The approach minimizes the squared difference in labels assigned to different objects, where the contribution of each difference to the loss is weighted by the affinity between the objects. The default in this implementation is to use a knn adjacency matrix based on euclidean distance to determine this weight. Setting adjacency="heat" will use an RBF kernel over euclidean distances between objects to determine the weights.
GRFClassifierSSLR( adjacency = "nn", adjacency_distance = "euclidean", adjacency_k = 6, adjacency_sigma = 0.1, class_mass_normalization = TRUE, scale = FALSE, x_center = FALSE )
| adjacency | character; "nn" for nearest neighbour graph or "heat" for radial basis adjacency matrix |
|---|---|
| adjacency_distance | character; distance metric for nearest neighbour adjacency matrix |
| adjacency_k | integer; number of neighbours for the nearest neighbour adjacency matrix |
| adjacency_sigma | double; width of the rbf adjacency matrix |
| class_mass_normalization | logical; Should the Class Mass Normalization heuristic be applied? (default: TRUE) |
| scale | logical; Should the features be normalized? (default: FALSE) |
| x_center | logical; Should the features be centered? |
Collobert, R. et al., 2006. Large scale transductive SVMs. Journal of Machine Learning Research, 7, pp.1687-1712.
library(tidyverse) library(caret) library(SSLR) library(tidymodels) data(wine) cls <- which(colnames(wine) == "Wine") #% LABELED labeled.index <- createDataPartition(wine$Wine, p = .2, list = FALSE) wine[-labeled.index,cls] <- NA m <- GRFClassifierSSLR() %>% fit(Wine ~ ., data = wine) #Predictions of unlabeled preds_unlabeled <- m %>% predictions() print(preds_unlabeled)#> # A tibble: 141 x 1 #> .pred_class #> <fct> #> 1 1 #> 2 1 #> 3 1 #> 4 1 #> 5 1 #> 6 1 #> 7 1 #> 8 1 #> 9 1 #> 10 1 #> # ... with 131 more rows#> [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 #> [38] 1 1 1 1 1 1 1 1 1 1 3 3 2 3 2 3 2 2 2 1 2 2 1 1 2 2 3 1 2 2 3 3 3 2 2 2 3 #> [75] 3 2 2 1 3 3 2 3 2 2 3 2 2 2 3 2 3 2 2 2 2 3 2 2 2 2 2 2 3 3 3 2 3 3 3 3 3 #> [112] 3 1 2 1 1 2 3 3 2 3 2 2 3 2 1 3 3 3 3 2 3 3 1 3 2 3 1 1 1 2 #> Levels: 1 2 3#Total y_total <- wine[,cls] y_total[-labeled.index] <- preds_unlabeled