View source: R/predict.R View source: R/civic_fit.R
| predict.civic_model | R Documentation |
Generates predictions from a fitted 'civic_model' object for any task type.
## S3 method for class 'civic_model'
predict(object, newdata, type = c("class", "prob"), threshold = 0.5, ...)
object |
A 'civic_model'. |
newdata |
A 'data.frame' for prediction. Must contain the same feature columns used during training. |
type |
For classification: '"class"' (default) returns predicted class labels as a factor; '"prob"' returns a matrix of class probabilities (one column per class). For regression: ignored — always returns a numeric vector. |
threshold |
Decision threshold for **binary** classification only (default 0.5). Ignored for multi-class and regression. |
... |
Ignored. |
For classification with 'type = "class"': a factor vector. For classification with 'type = "prob"': a numeric matrix. For regression: a numeric vector.
data(civic_voting)
m <- civic_fit(voted ~ age + education, data = civic_voting)
predict(m, civic_voting[1:5, ], type = "class")
predict(m, civic_voting[1:5, ], type = "prob")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.