predict.spa(spa)
predict.spa()所属R语言包:spa
Inductive Predict Procedure For SPA
电感的预测过程的水疗
译者:生物统计家园网 机器人LoveR
描述----------Description----------
This implements the inductive prediction for an spa object. The impact of the observation(s) on the existing labeled and unlabeled data is ignored.
这实现了感性的预测温泉对象。影响的观察(S)对现有的标记和未标记的数据将被忽略。
For transductive predicton use update function.
对于直推式的预测中使用update函数。
用法----------Usage----------
## S3 method for class 'spa'
参数----------Arguments----------
参数:object
an existing object of type spa
现有对象类型spa,
参数:xnew
the new xdata to predict, of diminsion ngXdim(object[2]) (only applicable if object was called with x data)
新的XDATA预测,diminsion ngXdim(对象[2])(仅适用对象被称为X数据)
参数:gnew
the new graph links. The diminsion on this matrix is ngX dim(object)[1] with ng as the number of observations to predict.
新的图形链接。这个矩阵的diminsion是NGX昏暗的(对象)[1] ng的若干意见,预测的。
参数:type
the type of prediction to return.
返回类型的预测。
参数:...
additional arguments passed into the function.
额外的参数传递给函数的。
(作者)----------Author(s)----------
Mark Culp
参考文献----------References----------
M. Culp (2011). spa: A Semi-Supervised R Package for Semi-Parametric Graph-Based Estimation. Journal of Statistical Software, 40(10), 1-29. URL http://www.jstatsoft.org/v40/i10/.
实例----------Examples----------
## Use simulated example (two moon) and generate a contour plot of the border[#使用模拟的例子(两个月亮)和生成的等高线图的边界]
set.seed(100)
dat=spa.sim(type="moon")
L=which(!is.na(dat$y))
U=which(is.na(dat$y))
Dij=as.matrix(daisy(dat[,-1]))
##Use spa to train with a supervised/transductive kernel smoother[#使用水疗中心,训练与顺畅一个监督/直推式内核]
gsup<-spa(dat$y[L],graph=Dij[L,L],control=spa.control(gcv="lGCV"))
gsemi<-spa(dat$y,graph=Dij,control=spa.control(gcv="aGCV"))
##Use predict to define a grid for contour plot[使用预测来定义一个网格,等高线图]
gsize=100
a1<-seq(min(dat$x1),max(dat$x1),length=gsize)
a2<-seq(min(dat$x2),max(dat$x2),length=gsize)
zsup=matrix(0,gsize,gsize)
for(i in 1:gsize){
val=sqrt(t(sapply(1:gsize,function(j)(dat$x1[L]-a1[i])^2+(dat$x2[L]-a2[j])^2)))
zsup[i,]=predict(gsup,gnew=val) ##supervised prediction with k-smoother[#监督的k-平滑预测]
}
zsemi=matrix(0,gsize,gsize)
for(i in 1:gsize){
val=sqrt(t(sapply(1:gsize,function(j)(dat$x1-a1[i])^2+(dat$x2-a2[j])^2)))
zsemi[i,]=predict(gsemi,gnew=val) ##inductive prediction with transductive rule[#感性预测与直推式规则]
}
## Plot results[#图结果]
gr=c(2,4)
plot(0,1,cex=1.5,xlab="x1",ylab="x2",type="n",
xlim=c(-0.5,6.5),ylim=c(-6.5,3.5))
gr=gray(c(.7,.9))
points(dat$x1,dat$x2,pch=16,col=8,cex=1)
points(dat$x1[L],dat$x2[L],pch=16,col=gr[dat$y[L]+1],cex=2)
points(dat$x1[L],dat$x2[L],pch=1,col=1,cex=2)
contour(a1,a2,zsup, levels=.5,add=TRUE,lty=1,method="edge",drawlabels=FALSE,lwd=2,col=gray(0.6))
contour(a1,a2,zsemi,levels=.5,add=TRUE,lty=1,method="edge",drawlabels=FALSE,lwd=2,col=1)
exp1=expression(hat(Y)*"="*hat(f)(G[X]))
exp2=expression(Y[L]*"="*f(X[L])+epsilon)
legend(4.25,par()$usr[4],c(exp1,exp2),cex=1.24,fill=gray(c(0,0.6)),bg="white")
legend(4.25,par()$usr[4],c(exp1,exp2),cex=1.24,fill=gray(c(0,0.6)))
title(switch(attr(dat,"type"),moon="Two Moon Simulated Data",supervised="Supervised Border Simulated set"))
title("\n\nInductive Prediction with a Transductive Model",cex.main=1.1)
box()
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|