influence.predict.textmodel_affinity: Compute feature influence from a predicted textmodel_affinity...

View source: R/textmodel_affinity.R

influence.predict.textmodel_affinityR Documentation

Compute feature influence from a predicted textmodel_affinity object

Description

Computes the influence of features on scaled textmodel_affinity() applications.

Usage

## S3 method for class 'predict.textmodel_affinity'
influence(model, subset = !train, ...)

Arguments

model

a predicted textmodel_affinity() object

subset

whether to use all data or a subset (for instance, exclude the training set)

...

unused

Value

a named list classed as influence.predict.textmodel_affinity that contains

  • norm a document by feature class sparse matrix of normalised influence measures

  • count a vector of counts of each non-zero feature in the input matrix

  • rate the normalised feature count for each non-zero feature in the input matrix

  • mode an integer vector of 1 or 2 indicating the class which the feature is influencing, for each non-zero feature

  • levels a character vector of the affinity class labels

  • subset a logical vector indicating whether the document was included in the computation of influence; FALSE for documents assigned a class label in training the model

  • support logical vector for each feature matching the same return from predict.textmodel_affinity

See Also

influence.lm()

Examples

tmod <- textmodel_affinity(quanteda::data_dfm_lbgexample, y = c("L", NA, NA, NA, "R", NA))
pred <- predict(tmod)
influence(pred)

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