calc.loss: Calculate total loss of model (Squared hinge loss).

Description Usage Arguments Value Examples

Description

Calculate the loss for a model in predicting the -1/+1 labeling. If new text and labeling given, then calc loss on the new text and labeling. This can be useful for cross validation and train-test splits.

Usage

1
2
calc.loss(model.blob, new.text = NULL, new.labeling = NULL,
  loss = c("square.hinge", "square", "hinge"))

Arguments

model.blob

The model returned from textreg

new.text

New text (string or tm Corpus) to predict labeling for

new.labeling

Labeling to go with new text.

loss

Type of loss to calc for.

Value

Three numbers: total loss, loss from prediction, loss from penalty term

Examples

1
2
3
4
5
data( testCorpora )
res = textreg( c( "", "", "A", "A" ), c( -1, -1, 1, 1 ), C=1, Lq=1,
          convergence.threshold=0.00000001, verbosity=0 )
calc.loss( res )
calc.loss( res, new.text=c("A B C A"), new.labeling=c(1) )

textreg documentation built on May 2, 2019, 8:34 a.m.