Description Usage Arguments Value Examples
Once the run from main function msm
is done, msmpred
predicts
the class label for the given data. In this function, there is no need for an user
to modify any output. It simply takes a returned object from msm
function,
which is a list of lists, and new data.
1 |
X |
an (n\times p) data matrix. |
msmoutput |
output of |
print.progress |
a logical; |
a length-n vector of class labels.
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 | ## generate a toy example
set.seed(10)
alldat = gen.LP(n=500, K=2, iso.var=0.1)
## separate as train/test data
id.train = sample(1:1000, 800, replace=FALSE)
id.test = setdiff(1:1000, id.train)
train.dat = alldat$data[id.train,]
train.lab = alldat$class[id.train]
test.dat = alldat$data[id.test,]
test.lab = alldat$class[id.test]
## run MSM algorithm with K=2
maxiter = 10000
output2 = msm(train.dat, K=2, iter=maxiter)
test.pred = msmpred(test.dat, output2)
## visualize with axis Y and Z for the test data
tX = test.dat[,2]
tY = test.dat[,3]
opar <- par(mfrow=c(1,2))
plot(tX,tY,col=test.lab, pch=19,cex=0.5,main="true label")
plot(tX,tY,col=test.pred,pch=19,cex=0.5,main="predicted label")
par(opar)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.