Description Usage Arguments References Examples
View source: R/EMNearestMeanClassifier.R
model from RSSL package Semi-Supervised Nearest Mean Classifier using Expectation Maximization
Expectation Maximization applied to the nearest mean classifier assuming Gaussian classes with a spherical covariance matrix.
Starting from the supervised solution, uses the Expectation Maximization algorithm (see Dempster et al. (1977)) to iteratively update the means and shared covariance of the classes (Maximization step) and updates the responsibilities for the unlabeled objects (Expectation step).
1 | EMNearestMeanClassifierSSLR(method = "EM", scale = FALSE, eps = 1e-04)
|
method |
character; Currently only "EM" |
scale |
Should the features be normalized? (default: FALSE) |
eps |
Stopping criterion for the maximinimization |
Dempster, A., Laird, N. & Rubin, D., 1977. Maximum likelihood from incomplete data via the EM algorithm. Journal of the Royal Statistical Society. Series B, 39(1), pp.1-38.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | library(tidyverse)
library(tidymodels)
library(caret)
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 <- EMNearestMeanClassifierSSLR() %>% fit(Class ~ ., data = train)
#Accesing model from RSSL
model <- m$model
#Accuracy
predict(m,test) %>%
bind_cols(test) %>%
metrics(truth = "Class", estimate = .pred_class)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.