predict.textmodel_lr: Prediction from a fitted textmodel_lr object

View source: R/textmodel_lr.R

predict.textmodel_lrR Documentation

Prediction from a fitted textmodel_lr object

Description

predict.textmodel_lr() implements class predictions from a fitted logistic regression model.

Usage

## S3 method for class 'textmodel_lr'
predict(
  object,
  newdata = NULL,
  type = c("class", "probability"),
  force = TRUE,
  ...
)

## S3 method for class 'textmodel_lr'
coef(object, ...)

## S3 method for class 'textmodel_lr'
coefficients(object, ...)

Arguments

object

a fitted logistic regression textmodel

newdata

dfm on which prediction should be made

type

the type of predicted values to be returned; see Value

force

make newdata's feature set conformant to the model terms

...

not used

Value

predict.textmodel_lr() returns either a vector of class predictions for each row of newdata (when type = "class"), or a document-by-class matrix of class probabilities (when 'type = "probability"“).

coef.textmodel_lr() returns a (sparse) matrix of coefficients for each feature, computed at the value of the penalty parameter fitted in the model. For binary outcomes, results are returned only for the class corresponding to the second level of the factor response; for multinomial outcomes, these are computed for each class.

See Also

textmodel_lr()


quanteda.textmodels documentation built on Sept. 11, 2024, 8:19 p.m.