Description Usage Arguments Value Author(s) Examples
Compute error rates.
If type = "rate"
then the misclassification rates will be computed.
If type = "count"
then the misclassification counts will be computed.
If type = "loglike"
then the negative log likelihood error will be computed.
1 2 3 |
object |
a msgl object |
data |
a matrix of |
response |
a vector of classes |
classes |
a vector of classes |
type |
type of error rate |
... |
ignored |
a vector of error rates
Martin Vincent
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | data(SimData)
x.all <- x
x.1 <- x[1:50,]
x.2 <- x[51:100,]
classes.all <- classes
classes.1 <- classes[1:50]
classes.2 <- classes[51:100]
#### Fit models using x.1
lambda <- msgl::lambda(x.1, classes.1, alpha = .5, d = 25, lambda.min = 0.075)
fit <- msgl::fit(x.1, classes.1, alpha = .5, lambda = lambda)
#### Training errors:
# Misclassification rate
Err(fit, x.1)
# Misclassification count
Err(fit, x.1, type = "count")
# Negative log likelihood error
Err(fit, x.1, type="loglike")
# Misclassification rate of x.2
Err(fit, x.2, classes.2)
#### Do cross validation
fit.cv <- msgl::cv(x.all, classes.all, alpha = .5, lambda = lambda)
#### Cross validation errors (estimated expected generalization error)
# Misclassification rate
Err(fit.cv)
# Negative log likelihood error
Err(fit.cv, type="loglike")
#### Do subsampling
test <- list(1:20, 21:40)
train <- lapply(test, function(s) (1:length(classes.all))[-s])
fit.sub <- msgl::subsampling(x.all, classes.all, alpha = .5,
lambda = lambda, training = train, test = test)
# Mean misclassification error of the tests
Err(fit.sub)
# Negative log likelihood error
Err(fit.sub, type="loglike")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.