A predict generic function for condvis
CVpredict(
fit,
newdata,
...,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL,
pinterval = NULL,
pinterval_level = 0.95
)# S3 method for default
CVpredict(
fit,
newdata,
...,
ptype = "pred",
pthreshold = NULL,
pinterval = NULL,
pinterval_level = 0.95,
ylevels = NULL,
ptrans = NULL
)
# S3 method for lm
CVpredict(
fit,
newdata,
...,
ptype = "pred",
pthreshold = NULL,
pinterval = NULL,
pinterval_level = 0.95,
ylevels = NULL,
ptrans = NULL
)
# S3 method for glm
CVpredict(
fit,
...,
type = "response",
ptype = "pred",
pthreshold = NULL,
pinterval = NULL,
pinterval_level = 0.95,
ylevels = NULL,
ptrans = NULL
)
# S3 method for lda
CVpredict(
fit,
...,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
# S3 method for qda
CVpredict(
fit,
...,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
# S3 method for nnet
CVpredict(
fit,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
# S3 method for randomForest
CVpredict(
fit,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
# S3 method for ranger
CVpredict(
fit,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
# S3 method for rpart
CVpredict(
fit,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
# S3 method for tree
CVpredict(
fit,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
# S3 method for C5.0
CVpredict(
fit,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
# S3 method for svm
CVpredict(
fit,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
# S3 method for gbm
CVpredict(
fit,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
n.trees = fit$n.trees,
ptrans = NULL
)
# S3 method for loess
CVpredict(fit, newdata = NULL, ...)
# S3 method for ksvm
CVpredict(
fit,
newdata,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
# S3 method for glmnet
CVpredict(
fit,
newdata,
...,
type = "response",
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL,
s = NULL,
makex = NULL
)
# S3 method for cv.glmnet
CVpredict(
fit,
newdata,
...,
type = "response",
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL,
makex = NULL
)
# S3 method for glmnet.formula
CVpredict(
fit,
newdata,
...,
type = "response",
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL,
s = NULL
)
# S3 method for cv.glmnet.formula
CVpredict(
fit,
newdata,
...,
type = "response",
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
# S3 method for keras.engine.training.Model
CVpredict(
fit,
newdata,
...,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL,
batch_size = 32,
response = NULL,
predictors = NULL
)
# S3 method for kde
CVpredict(fit, newdata = fit$x, ..., scale = TRUE)
# S3 method for densityMclust
CVpredict(
fit,
newdata = NULL,
...,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL,
scale = TRUE
)
# S3 method for MclustDA
CVpredict(
fit,
newdata,
...,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
# S3 method for MclustDR
CVpredict(
fit,
newdata,
...,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
# S3 method for Mclust
CVpredict(
fit,
newdata,
...,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
# S3 method for train
CVpredict(
fit,
newdata,
...,
type = "response",
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
# S3 method for bartMachine
CVpredict(
fit,
newdata,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
# S3 method for model_fit
CVpredict(
fit,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL,
pinterval = NULL,
pinterval_level = 0.95
)
# S3 method for WrappedModel
CVpredict(
fit,
newdata,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL,
pinterval = NULL,
pinterval_level = 0.95
)
# S3 method for Learner
CVpredict(
fit,
newdata,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL,
pinterval = NULL,
pinterval_level = 0.95
)
a vector of predictions, or a matrix when type is "probmatrix"
A fitted model
Where to calculate predictions.
extra arguments to predict
One of "pred","prob" or "probmatrix"
Used for calculating classes from probs, in the two class case
The levels of the response, when it is a factor
A function to apply to the result
NULL, "confidence" or "prediction". Only for lm, parsnip, mlr(regression, confidence only)
Defaults to 0.95
For some predict methods
Used by CVpredict.gbm, passed to predict
Used by CVpredict.glmnet and CVpredict.cv.glmnet, passed to predict
Used by CVpredict.glmnet and CVpredict.cv.glmnet. A function to construct xmatrix for predict.
Used by CVpredict.keras.engine.training.Model, passed to predict
Used by CVpredict.keras.engine.training.Model. Name of response (optional)
Used by CVpredict.keras.engine.training.Model. Name of predictors
Used by CVpredict for densities. If TRUE (default) rescales the conditional density to integrate to 1.
default
: CVpredict method
lm
: CVpredict method
glm
: CVpredict method
lda
: CVpredict method
qda
: CVpredict method
nnet
: CVpredict method
randomForest
: CVpredict method
ranger
: CVpredict method
rpart
: CVpredict method
tree
: CVpredict method
C5.0
: CVpredict method
svm
: CVpredict method
gbm
: CVpredict method
loess
: CVpredict method
ksvm
: CVpredict method
glmnet
: CVpredict method
cv.glmnet
: CVpredict method
glmnet.formula
: CVpredict method
cv.glmnet.formula
: CVpredict method
keras.engine.training.Model
: CVpredict method
kde
: CVpredict method
densityMclust
: CVpredict method
MclustDA
: CVpredict method
MclustDR
: CVpredict method
Mclust
: CVpredict method
train
: CVpredict method for caret
bartMachine
: CVpredict method
model_fit
: CVpredict method for parsnip
WrappedModel
: CVpredict method for mlr
Learner
: CVpredict method for mlr3
This is a wrapper for predict used by condvis. When the model response is numeric, the result is a vector of predictions. When the model response is a factor the result depends on the value of ptype. If ptype="pred", the result is a factor. If also threshold is numeric, it is used to threshold a numeric prediction to construct the factor when the factor has two levels. For ptype="prob", the result is a vector of probabilities for the last factor level. For ptype="probmatrix", the result is a matrix of probabilities for each factor level.
#Fit a model.
f <- lm(Fertility~ ., data=swiss)
CVpredict(f)
#Fit a model with a factor response
swiss1 <- swiss
swiss1$Fertility <- cut(swiss$Fertility, c(0,80,100))
levels(swiss1$Fertility)<- c("lo", "hi")
f <- glm(Fertility~ ., data=swiss1, family="binomial")
CVpredict(f) # by default gives a factor
CVpredict(f, ptype="prob") # gives prob of level hi
CVpredict(f, ptype="probmatrix") # gives prob of both levels
Run the code above in your browser using DataLab