Similar to other predict methods, this function predicts fitted values from a fitted "CRF“ object.

# S3 method for CRF
predict(model, data, used.cols = NULL, thread.ratio = NULL)

Format

S3 methods

Arguments

model

R6Class object
A "CRF" object for prediction.

data

DataFrame
DataFrame containting the data.

used.cols

list of characters, optional
This parameter specifies the three columns used for training a conditional random field model. Namely, one column should correspond to Document ID, another column should correspond to word position, and a 3rd column corresponds to word. If not NULL, this parameter should be specified in two ways:

  • (1) used.cols = list("document.id" = "xxx", "word.pos" = "yyy", "word" = "zzz")

  • (2) used.cols = list("xxx", "yyy", "zzz")

In case (2), "xxx", "yyy" and "zzz" must be the column data of document ID, word position and word respectively.
Defaults to the first three column names of data if not provided.

thread.ratio

double, optional
Controls the proportion of available threads that can be used by this function.
The value range is from 0 to 1, where 0 indicates a single thread, and 1 indicates all available threads.
Values between 0 and 1 will use up to that percentage of available threads.Values outside this range are ignored.
Defaults to 0.

Value

DataFrame
Prediction result, structured as follows:

  • 1st column: document ID

  • 2nd column: word position

  • 3rd column: label

Examples

Call the function with a "CRF" object cf:


> predict(cf, data)

See also