CVpredict {condvis2} | R Documentation |
A predict generic function for condvis
Description
A predict generic function for condvis
Usage
CVpredict(
fit,
newdata,
...,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL,
pinterval = NULL,
pinterval_level = 0.95
)
## Default S3 method:
CVpredict(
fit,
newdata,
...,
ptype = "pred",
pthreshold = NULL,
pinterval = NULL,
pinterval_level = 0.95,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'lm'
CVpredict(
fit,
newdata,
...,
ptype = "pred",
pthreshold = NULL,
pinterval = NULL,
pinterval_level = 0.95,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'glm'
CVpredict(
fit,
...,
type = "response",
ptype = "pred",
pthreshold = NULL,
pinterval = NULL,
pinterval_level = 0.95,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'lda'
CVpredict(
fit,
...,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'qda'
CVpredict(
fit,
...,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'nnet'
CVpredict(
fit,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'randomForest'
CVpredict(
fit,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'ranger'
CVpredict(
fit,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'rpart'
CVpredict(
fit,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'tree'
CVpredict(
fit,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'C5.0'
CVpredict(
fit,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'svm'
CVpredict(
fit,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'gbm'
CVpredict(
fit,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
n.trees = fit$n.trees,
ptrans = NULL
)
## S3 method for class 'loess'
CVpredict(fit, newdata = NULL, ...)
## S3 method for class 'ksvm'
CVpredict(
fit,
newdata,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'glmnet'
CVpredict(
fit,
newdata,
...,
type = "response",
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL,
s = NULL,
makex = NULL
)
## S3 method for class 'cv.glmnet'
CVpredict(
fit,
newdata,
...,
type = "response",
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL,
makex = NULL
)
## S3 method for class 'glmnet.formula'
CVpredict(
fit,
newdata,
...,
type = "response",
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL,
s = NULL
)
## S3 method for class 'cv.glmnet.formula'
CVpredict(
fit,
newdata,
...,
type = "response",
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class '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 class 'kde'
CVpredict(fit, newdata = fit$x, ..., scale = TRUE)
## S3 method for class 'densityMclust'
CVpredict(
fit,
newdata = NULL,
...,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL,
scale = TRUE
)
## S3 method for class 'MclustDA'
CVpredict(
fit,
newdata,
...,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'MclustDR'
CVpredict(
fit,
newdata,
...,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'Mclust'
CVpredict(
fit,
newdata,
...,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'train'
CVpredict(
fit,
newdata,
...,
type = "response",
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'bartMachine'
CVpredict(
fit,
newdata,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'wbart'
CVpredict(
fit,
newdata,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'lbart'
CVpredict(
fit,
newdata,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'pbart'
CVpredict(
fit,
newdata,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'bart'
CVpredict(
fit,
newdata,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL
)
## S3 method for class 'model_fit'
CVpredict(
fit,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL,
pinterval = NULL,
pinterval_level = 0.95
)
## S3 method for class 'WrappedModel'
CVpredict(
fit,
newdata,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL,
pinterval = NULL,
pinterval_level = 0.95
)
## S3 method for class 'Learner'
CVpredict(
fit,
newdata,
...,
type = NULL,
ptype = "pred",
pthreshold = NULL,
ylevels = NULL,
ptrans = NULL,
pinterval = NULL,
pinterval_level = 0.95
)
Arguments
fit |
A fitted model |
newdata |
Where to calculate predictions. |
... |
extra arguments to predict |
ptype |
One of "pred","prob" or "probmatrix" |
pthreshold |
Used for calculating classes from probs, in the two class case |
ylevels |
The levels of the response, when it is a factor |
ptrans |
A function to apply to the result |
pinterval |
NULL, "confidence" or "prediction". Only for lm, parsnip, mlr(regression, confidence only) |
pinterval_level |
Defaults to 0.95 |
type |
For some predict methods |
n.trees |
Used by CVpredict.gbm, passed to predict |
s |
Used by CVpredict.glmnet and CVpredict.cv.glmnet, passed to predict |
makex |
Used by CVpredict.glmnet and CVpredict.cv.glmnet. A function to construct xmatrix for predict. |
batch_size |
Used by CVpredict.keras.engine.training.Model, passed to predict |
response |
Used by CVpredict.keras.engine.training.Model. Name of response (optional) |
predictors |
Used by CVpredict.keras.engine.training.Model. Name of predictors |
scale |
Used by CVpredict for densities. If TRUE (default) rescales the conditional density to integrate to 1. |
Details
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.
Value
a vector of predictions, or a matrix when type is "probmatrix"
Methods (by class)
-
CVpredict(default)
: CVpredict method -
CVpredict(lm)
: CVpredict method -
CVpredict(glm)
: CVpredict method -
CVpredict(lda)
: CVpredict method -
CVpredict(qda)
: CVpredict method -
CVpredict(nnet)
: CVpredict method -
CVpredict(randomForest)
: CVpredict method -
CVpredict(ranger)
: CVpredict method -
CVpredict(rpart)
: CVpredict method -
CVpredict(tree)
: CVpredict method -
CVpredict(C5.0)
: CVpredict method -
CVpredict(svm)
: CVpredict method -
CVpredict(gbm)
: CVpredict method -
CVpredict(loess)
: CVpredict method -
CVpredict(ksvm)
: CVpredict method -
CVpredict(glmnet)
: CVpredict method -
CVpredict(cv.glmnet)
: CVpredict method -
CVpredict(glmnet.formula)
: CVpredict method -
CVpredict(cv.glmnet.formula)
: CVpredict method -
CVpredict(keras.engine.training.Model)
: CVpredict method -
CVpredict(kde)
: CVpredict method -
CVpredict(densityMclust)
: CVpredict method -
CVpredict(MclustDA)
: CVpredict method -
CVpredict(MclustDR)
: CVpredict method -
CVpredict(Mclust)
: CVpredict method -
CVpredict(train)
: CVpredict method for caret -
CVpredict(bartMachine)
: CVpredict method -
CVpredict(wbart)
: CVpredict method -
CVpredict(lbart)
: CVpredict method -
CVpredict(pbart)
: CVpredict method -
CVpredict(bart)
: CVpredict method -
CVpredict(model_fit)
: CVpredict method for parsnip -
CVpredict(WrappedModel)
: CVpredict method for mlr -
CVpredict(Learner)
: CVpredict method for mlr3
Examples
#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