data(abr1)
cl <- factor(abr1$fact$class)
dat <- abr1$pos
## divide data as training and test data
idx <- sample(1:nrow(dat), round((2/3)*nrow(dat)), replace=FALSE)
## construct train and test data
train.dat <- dat[idx,]
train.t <- cl[idx]
test.dat <- dat[-idx,]
test.t <- cl[-idx]
## apply pcalda
model <- pcalda(train.dat,train.t)
model
summary(model)
## plot
plot(model,dimen=c(1,2),main = "Training data",abbrev = TRUE)
plot(model,main = "Training data",abbrev = TRUE)
## confusion matrix
pred.te <- predict(model, test.dat)$class
table(test.t,pred.te)
Run the code above in your browser using DataLab