predict.civic_model: Predict from a civic_model

View source: R/predict.R View source: R/civic_fit.R

predict.civic_modelR Documentation

Predict from a civic_model

Description

Generates predictions from a fitted 'civic_model' object for any task type.

Usage

## S3 method for class 'civic_model'
predict(object, newdata, type = c("class", "prob"), threshold = 0.5, ...)

Arguments

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.

Value

For classification with 'type = "class"': a factor vector. For classification with 'type = "prob"': a numeric matrix. For regression: a numeric vector.

Examples

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")

civic.icarm documentation built on June 18, 2026, 1:06 a.m.