EntropyRegularizedLogisticRegressionSSLR.Rdmodel from RSSL package R Implementation of entropy regularized logistic regression implementation as proposed by Grandvalet & Bengio (2005). An extra term is added to the objective function of logistic regression that penalizes the entropy of the posterior measured on the unlabeled examples.
EntropyRegularizedLogisticRegressionSSLR( lambda = 0, lambda_entropy = 1, intercept = TRUE, init = NA, scale = FALSE, x_center = FALSE )
| lambda | l2 Regularization |
|---|---|
| lambda_entropy | Weight of the labeled observations compared to the unlabeled observations |
| intercept | logical; Whether an intercept should be included |
| init | Initial parameters for the gradient descent |
| scale | logical; Should the features be normalized? (default: FALSE) |
| x_center | logical; Should the features be centered? |
Grandvalet, Y. & Bengio, Y., 2005. Semi-supervised learning by entropy minimization. In L. K. Saul, Y. Weiss, & L. Bottou, eds. Advances in Neural Information Processing Systems 17. Cambridge, MA: MIT Press, pp. 529-536.
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 m <- EntropyRegularizedLogisticRegressionSSLR() %>% fit(Class ~ ., data = train) #Accuracy predict(m,test) %>% bind_cols(test) %>% metrics(truth = "Class", estimate = .pred_class)#> Warning: la longitud de los datos [34] no es un submúltiplo o múltiplo del número de filas [35] en la matriz#> # A tibble: 2 x 3 #> .metric .estimator .estimate #> <chr> <chr> <dbl> #> 1 accuracy binary 0.706 #> 2 kap binary 0.0899