predictLabelFromText
Predict a label for each event in the table using the model that was created by the createModelFromText operator, which learns how to predict labels from a text.
For example, consider a table with two columns: list of all cities in a country (comma-separated string) be first column and country name. The task is to train a model that can identify country name from a list of cities. The list of cities in the prediction can be incomplete compared to the training list. For instance, adding "Cleveland, London, Paris, Venice" would predict "USA" because cities with all four of the names are found in the USA in addition to other countries.
Cleveland, London => USA, England
Paris => France, USA(CA)
Venice => Italy, USA(FL)
Operator Usage in Easy Mode
- Click + on the parent node.
- Enter the Predict Label from Text operator in the search field and select the operator from the Results to open the operator form.
- In the Table drop-down, enter or select the name of the table to apply the prediction.
- In the Model Name drop-down, enter or select the name of the model.
- Optional. In the Column Names, click Add More to add the list of column names used to predict the label.
- Click Run to view the result.
- Click Save to add the operator to the playbook.
- Click Cancel to discard the operator form.
Usage Details
LQL Command
predictLabelFromText(table, outputModelName, listOfColumns)
Input
table
: Input table to train a model.
outputModelName
: Model name that was created using the createModelFromText operator. Trained models are not displayed in the UI, so remember the name of the model that was created. If a model with the same name exists, this operation overwrites it without notification.
listOfColumns
: List of columns to use for prediction. The order must be the same as listOfColumns
during the training step.
Output
Input table plus an additional column: lhub_predicted_label
.
Example
Input
table = github_logs
id | title | description |
---|---|---|
1 | a, b | h, i |
1 | a, x | u, v |
LQL: "lettersToUser" is model name that was created from the example section of create model from text .
LQL command
predictLabelFromText(table,"scoreEmail", "title", "description")
Output
id | title | description | lhub_predicted_label |
---|---|---|---|
1 | a, b | h, i | spam |
1 | a, x | u, v | ham |