get.yhat {midr} | R Documentation |
Wrapper Prediction Function
Description
get.yhat()
works as a proxy prediction function for many classes of fitted models.
Usage
get.yhat(X.model, newdata, ...)
## Default S3 method:
get.yhat(X.model, newdata, target = -1L, ...)
## S3 method for class 'mid'
get.yhat(X.model, newdata, ...)
## S3 method for class 'lm'
get.yhat(X.model, newdata, ...)
## S3 method for class 'glm'
get.yhat(X.model, newdata, ...)
## S3 method for class 'rpart'
get.yhat(X.model, newdata, target = -1L, ...)
## S3 method for class 'randomForest'
get.yhat(X.model, newdata, target = -1L, ...)
## S3 method for class 'ranger'
get.yhat(X.model, newdata, target = -1L, ...)
## S3 method for class 'svm'
get.yhat(X.model, newdata, target = -1L, ...)
## S3 method for class 'ksvm'
get.yhat(X.model, newdata, target = -1L, ...)
## S3 method for class 'AccurateGLM'
get.yhat(X.model, newdata, ...)
## S3 method for class 'glmnet'
get.yhat(X.model, newdata, ...)
## S3 method for class 'model_fit'
get.yhat(X.model, newdata, target = -1L, ...)
## S3 method for class 'rpf'
get.yhat(X.model, newdata, target = -1L, ...)
Arguments
X.model |
a fitted model object. |
newdata |
a data.frame or matrix. |
... |
optional parameters that are passed to the prediction method for the model. |
target |
an integer or character vector specifying the target levels for the prediction, used for the models that returns a matrix or data.frame of class probabilities. Default is |
Details
get.yhat()
is a wrapper prediction function for many classes of models.
Although many predictive models have their own method of stats::predict()
, the structure and the type of the output of these methods are not uniform.
get.yhat()
is designed to always return a simple numeric vector of model predictions.
The design of get.yhat()
is strongly influenced by DALEX::yhat()
.
Value
get.yhat()
returns a numeric vector of model predictions for the newdata
.
Examples
data(trees, package = "datasets")
model <- glm(Volume ~ ., trees, family = Gamma(log))
predict(model, trees[1:5, ], type = "response")
get.yhat(model, trees[1:5, ])