Learn R Programming

quanteda.textmodels (version 0.9.9)

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

Description

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

Usage

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

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

Arguments

model

a predicted textmodel_affinity() object

subset

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

...

unused

See Also

Examples

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

Run the code above in your browser using DataLab