View source: R/prediction_code.R
| calc.loss | R Documentation |
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.
calc.loss(
model.blob,
new.text = NULL,
new.labeling = NULL,
loss = c("square.hinge", "square", "hinge")
)
model.blob |
The model returned from |
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. |
Three numbers: total loss, loss from prediction, loss from penalty term
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) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.